neerc-2010-g
The Game of 10 is played by two players on a 4 x 4 field. Initially all 16 cells of the field are empty. Players make alternating moves. On each move a player writes a number from 1 to 4 into an empty cell. The fist player that makes any row or column filled with four numbers with a sum of 10 wins. If all cells are filled but no row or column has a sum of 10, then a draw is declared.
You have to write a program that plays for the second player and always wins.
The table below shows the field after the sample game that is shown in the "Sample input and output" section. Subscripts denote the number of the move in the game starting from the first one, with 14-th being the last and winning move by the second player. The last move in the game had filled the second column with a sum of 10.
Interaction protocol
The interaction starts with your program reading the first player's move from the standard input. Then your program must write its move to the standard output, wait for the first player's move in the standard input and so on.
Your program must exit after writing the last, winning move to the standard output. Your program must write end-of-line sequence and flush the standard output after each move, including the last, winning move.
], and k (1 <= r; c; k <= 4) separated by spaces, where r and c are row and column numbers, and k is the number that the first player writes into the cell (r, c).by a space.
Input:
2 2 2
1 1 1
2 4 2
2 1 1
3 4 4
3 1 3
1 2 4
Output:
3 3 3
4 4 4
4 2 3
1 3 2
1 4 2
4 1 3
3 2 1 WIN
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.