#C1559. Capture the Flags
Capture the Flags
Capture the Flags
In this problem, you are asked to simulate a game called "Capture the Flags" played on a 5×5 grid. Two players start at opposite corners: Player 1 at (1,1) and Player 2 at (5,5). A number of flags are placed on the grid. The grid cells are numbered using the formula ( index = (x-1)\times5 + y ), where ( (x, y) ) represents a cell's row and column respectively.
The game is simulated by a list of moves. Each move is represented by three integers: the player number and the new coordinates (new_x, new_y) to which the player moves. When a player moves, if the new position is valid (i.e. it lies within the grid) and contains a flag, the player captures the flag (increasing his score by 1) and the flag is removed from the grid. The game stops once all flags have been captured or all moves have been processed.
At the end, if Player 1 has captured more flags, the output is "Player 1 wins". If Player 2 has captured more flags, the output is "Player 2 wins". Otherwise, the result is "Draw".
inputFormat
The input is given from standard input (stdin) in the following format:
- The first line contains an integer ( n ) representing the number of moves.
- The following ( n ) lines each contain three space-separated integers: ( player ) (either 1 or 2), ( new_x ), and ( new_y ).
- The next line contains an integer ( m ) representing the number of flags placed on the grid.
- The following line contains ( m ) space-separated integers, each indicating the position of a flag (calculated using the formula ( index = (x-1)\times5 + y )).
outputFormat
Print a single line to standard output (stdout) containing one of the following strings: "Player 1 wins", "Player 2 wins", or "Draw".## sample
9
1 1 2
2 5 4
1 1 3
2 4 4
1 1 4
2 3 4
1 1 5
2 3 3
1 2 5
5
2 3 4 19 14
Player 1 wins
</p>