QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100

#15766. 选择相机

统计

Strange 先生正在挑选一款便携式数码相机。他浏览了不同商店的报价,并有时会做出临时选择。在每次做出临时选择时,他只知道自己已经看过的所有报价,而不知道未来会看到的报价。

在 Strange 先生看来,任何数码相机都可以由两个属性完全描述:像素数和光学变焦倍数。对于每个属性,他都认为越大越好。Strange 先生害怕买到过时的相机,因此如果他知道有另一款相机在某一个属性上严格更好且在另一个属性上不比它差,他就绝不会选择这款相机。在所有 Strange 先生认为不过时的相机中,他会选择价格最便宜的一款;如果存在多款价格相同且均为最低的非过时相机,他会选择其中最早被提供(即出现最早)的那一款。

输入格式

输入的第一行包含测试用例的数量。

每个测试用例的第一行包含总操作数 $n$($1 \le n \le 10^5$)。

接下来的 $n$ 行中,每行代表一个操作。操作可以是新相机报价或临时选择:

  • 新相机报价用大写字母 P 表示,后跟相机的像素数、变焦倍数和价格。
  • 临时选择用大写字母 C 表示。

每个操作独占一行,行内的数据用单个空格分隔。

数据范围

  • 像素数 $p_i$ 为整数,范围在 $10^3 \le p_i \le 10^9$ 之间。
  • 变焦倍数 $z_i$ 为浮点数,范围在 $1 \le z_i \le 100$ 之间,且小数点后最多有 6 位数字。
  • 价格 $c_i$ 为整数,范围在 $1 \le c_i \le 10^6$ 之间。
  • 输入文件的大小小于 16 MB。

输出格式

对于每个临时选择操作(C),你的程序应当输出当前选择的相机被提供时的操作编号(操作编号从 1 开始)。如果根据规则无法做出选择,则该查询的结果应为 -1

每个测试用例的所有结果应输出在同一行中,并用单个空格分隔。相邻测试用例的结果应输出在连续的行中。

样例

输入 1

2
1
P 9600000 7 72
7
P 1200000 1 40
P 7200000 5 100
C
P 9600000 3 200
C
P 7200000 12 220
C

输出 1

2 2 4

说明

输出的第一行是空的,因为第一个测试用例中不包含 C 操作。

在第二个测试用例的第一次选择中,报价 1(1200000 1 40)已过时,因此报价 2(7200000 5 100)是唯一的选择,也是最好的选择。

在第二次选择中,依然选择报价 2,因为它的价格比报价 4(9600000 3 200)更便宜。

在第三次选择中,报价 6(7200000 12 220)使得报价 2(7200000 5 100)过时,因此报价 4(9600000 3 200)成为了非过时相机中最便宜的一款。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.