传统题 800ms 256MiB

A-2 Gala Night

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

It’s time for the company’s annual gala! To reward employees for their hard work over the past year, PAT Company has decided to hold a lucky draw. Each employee receives one or more tickets, each of which has a unique integer printed on it.

During the lucky draw, the host will perform one of the following actions:

  1. Announce a lucky number xx, and the winner is then the smallest number that is greater than or equal to xx.
  2. Ask a specific employee for all his/her tickets that have already won.
  3. Declare that the ticket with a specific number xx wins.

A ticket can win multiple times. Your job is to help the host determine the outcome of each action.

输入格式

The first line contains a positive integer NN ( 1N1051 \le N \le 10^5 ), representing the number of tickets.

The next NN lines each contains two parts separated by a space: an employee ID in the formatPATfollowed by a six-digit number (e.g.,PAT202412) and an integer xx ( 109x109-10^9 \le x \le 10^9 ), representing the number on the ticket.

Then the following line contains a positive integer QQ ( 1Q1051 \le Q \le 10^5 ), representing the number of actions.
The next QQ lines each contain one of the following three actions:

  1. 1 x: Declare the ticket with the smallest number that is greater than or equal to xx as the winner.
  2. 2 y: Ask the employee with ID yy all his/her tickets that have already won.
  3. 3 x: Declare the ticket with number xx as the winner.

It is guaranteed that there are no more than 100 actions of the 2nd type (2 y).

输出格式

For actions of type 1 and 3, output the employee ID holding the winning ticket. If no valid ticket exists, output ERROR.
For actions of type 2, if the employee ID yy does not exist, output ERROR. Otherwise, output all winning ticket numbers held by this employee in the same order of input. If no ticket wins, output an empty line instead.

题目示例数据

10
PAT000001 1
PAT000003 5
PAT000002 4
PAT000010 20
PAT000001 2
PAT000008 7
PAT000010 18
PAT000003 -5
PAT102030 -2000
PAT000008 15
11
1 10
2 PAT000008
2 PAT000001
3 -10
1 9999
1 -10
3 2
1 0
3 1
2 PAT000001
3 -2000
PAT000008
15

ERROR
ERROR
PAT000003
PAT000001
PAT000001
PAT000001
1 2
PAT102030

PAT2024冬季重现赛

未参加
状态
已结束
规则
IOI
题目
11
开始于
2025-7-27 14:00
结束于
2025-7-27 17:30
持续时间
3.5 小时
主持人
参赛人数
50