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:
- Announce a lucky number , and the winner is then the smallest number that is greater than or equal to .
- Ask a specific employee for all his/her tickets that have already won.
- Declare that the ticket with a specific number 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 ( ), representing the number of tickets.
The next 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 ( ), representing the number on the ticket.
Then the following line contains a positive integer ( ), representing the number of actions.
The next lines each contain one of the following three actions:
1 x: Declare the ticket with the smallest number that is greater than or equal to as the winner.2 y: Ask the employee with ID all his/her tickets that have already won.3 x: Declare the ticket with number 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 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