| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 8 초 (추가 시간 없음) | 1024 MB | 71 | 24 | 24 | 61.538% |
In a deterministic version of Musical Chairs1, there are $n$ chairs placed in a circle. The chairs are numbered from 1ドル$ to $n$ in clockwise order. Initially, the $i$th player sits on the $i$th chair. During the game, the game master gives commands to all players at once.
The first type of command tells each player to move $x$ chairs farther in clockwise order, so they must move from chair $i$ to chair $i+x$.
The second type of command tells each player to move from chair $i$ to chair $i\cdot{}x$. Both these calculations are done modulo $n,ドル where a remainder of 0ドル$ corresponds to chair $n$.
If two or more people want to move to the same chair, then the player needing to travel the least in clockwise direction to reach the chair gets to take the seat, and the other players trying to reach the same chair are out of the game. This is illustrated in Figure C.1, where the larger circles represent the chairs and their numbers are written on their inside. The smaller circles represent the players. The next command (* 10) tells player 10ドル$ (now on seat 11ドル$) and player 4ドル$ (now on seat 5ドル$) to move to chair 2ドル$. However, since player 10ドル$ needs to travel less, this player gets to take the seat. Note that the other 10ドル$ players will also move to some other chairs, but this is omitted from the figure for the sake of readability.
Figure C.1: Illustration of Sample Input 1 at the fourth command, where players 4ドル$ and 10ドル$ need to move to chair 2ドル$. Because player 10ドル$ needs to travel less in clockwise direction, this player gets to take the seat.
The jury wasted most of their free time designing this game and now need to go back to work. Fortunately, the game is deterministic, so you can play the game without the help of the jury.
1You do not need to know the original game, but you can try to play it after the contest is over.
The input consists of:
+ $x$": The player on chair $i$ moves to chair $i+x$.* $x$": The player on chair $i$ moves to chair $i\cdot{}x$.? $x$": Tell us the number of the player on chair $x$.For each command of type '?', output the number of the player on the requested chair. If the chair is currently empty, output $-1$ instead.
12 10 ? 12 + 1 ? 12 * 10 ? 2 * 5 ? 2 * 6 ? 1 ? 12
12 11 10 6 -1 11
32 11 * 6 ? 8 * 6 + 31 * 28 ? 4 + 1 * 2 + 1 * 3 ? 1
28 32 32
ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2023 C번