#P9898. Winning Strategy in Pig Chess

    ID: 23043 Type: Default 1000ms 256MiB

Winning Strategy in Pig Chess

Winning Strategy in Pig Chess

This is an interactive game problem based on the rules of Pig Chess. Two players (black and white) take turns placing pieces on an initially empty 1000×1000 board. In each round, a player places two pieces at distinct unoccupied coordinates in a given order. When placing a piece, if a 2×2 square is formed composed entirely of pieces of the same color, the player who placed the piece wins immediately. The square is defined by positions \( (x,y), (x+1,y), (x,y+1), (x+1,y+1) \), all of the same color.

You are the first player and you are guaranteed to have a winning strategy within 100 rounds against an opponent controlled by the interactive judge. In each round:

  • You select two coordinates \( (x_1,y_1) \) and \( (x_2,y_2) \) such that \(1 \le x_1, y_1, x_2, y_2 \le 1000\). You must ensure that the first coordinate is unoccupied. Immediately after placing the first piece, if the move results in forming a homogeneous 2×2 square, you win and the game ends.
  • If not, you then ensure that the second coordinate is unoccupied and place your second piece. Again, if this move forms a 2×2 square of your color, you win immediately.
  • If neither move wins, the interactive judge will respond by placing two pieces of the opponent’s color (with given coordinates that satisfy the same conditions) unless the opponent wins or there are already 400 pieces on the board, which would then result in a draw.

Your task is to output a sequence of moves (each move consisting of two pairs of coordinates corresponding to a round) that guarantees your win. For the purpose of this problem, you may assume that the interactive process is simulated with predetermined inputs and that a winning sequence exists. One simple strategy is to set up the board so that by the second round your moves create the 2×2 square. For instance, by playing:

Round 1: Place pieces at (1,1) and (1,2)
Round 2: Place pieces at (2,1) and (2,2)

After Round 2, the board will have your pieces at (1,1), (1,2), (2,1) and (2,2), which forms a homogeneous 2×2 square and wins the game.

Note: In an interactive environment you would flush your outputs and process the opponent's moves. For this problem, assume that the provided test cases simulate the interactive responses. Your output must exactly follow the move sequence you choose.

inputFormat

This is an interactive problem. In the offline simulation, the input can be considered empty or contain dummy data representing the opponent's moves. You do not need to process any input in your solution.

outputFormat

Your program should output the moves you want to make. Each move consists of two pairs of coordinates. In the sample solution provided, two rounds of moves are printed. For example:

1 1 1 2
2 1 2 2

After printing these moves, your solution is considered to have won by forming a 2×2 homogeneous square.

sample

1 1 1 2

2 1 2 2

</p>