시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB17161191.667%

문제

Musical chairs is a game frequently played at children's parties. Players are seated in a circle facing outwards. When the music starts, the players have to stand up and move clockwise round the chairs. One chair is removed, and when the music stops the players all have to try to sit down on one of the chairs. The player who does not manage to sit down is out, and the game continues until there is just one player left, who is the winner.

입력

The first line contains a single integer, N which is the number of players (1 < N <= 15). The next N lines have the names of the players. The length of player's name does not exceed 10.

The next line contains R, an integer which tells how many rounds are to be processed (0 < R < N). The next R lines each contain a pair of integers S and M, separated by a space. S is the number of the seat to be removed. Seats are numbered from 1 to the number of seats remaining in a clockwise direction.

M is the number of moves made before the music stops (0 < M <= 30). A move takes a player from one seat to the next in a clockwise direction. A move from the highest seat number takes a player to seat 1.

출력

After each round has taken place, output a line

<name> has been eliminated.

where <name> is the name of the person who does not find a seat. This will be the person who would have ended up at the seat which was removed.

At the end of the specified number of moves, output a line which either says 

<name> has won.

where a single player remains, or 

Players left are <name list>.

where the game is not yet finished. 

<name list> contains the name of each player not yet eliminated in the same order as in the input. The names are separated by spaces.

예제 입력 1

5
Anne
Bill
Chen
Di
Everet
4
3 6
2 8
1 5
2 6

예제 출력 1

Bill has been eliminated.
Anne has been eliminated.
Chen has been eliminated.
Everet has been eliminated.
Di has won.

예제 입력 2

6
Ferdinand
Garcia
Henrietta
Isabel
Jacob
Kirstin
3
6 10
5 1
2 30

예제 출력 2

Garcia has been eliminated.
Kirstin has been eliminated.
Jacob has been eliminated.
Players left are Ferdinand Henrietta Isabel.

출처

ICPC > Regionals > South Pacific > South Pacific Region > New Zealand Programming Contest > NZPC 2017 F번

  • 잘못된 데이터를 찾은 사람: dotorya
  • 문제의 오타를 찾은 사람: jaehoo1