#C13812. Tic Tac Toe Game Simulation

    ID: 43392 Type: Default 1000ms 256MiB

Tic Tac Toe Game Simulation

Tic Tac Toe Game Simulation

Implement a Tic Tac Toe game simulation. The game is played on a 3×3 board between two players: X and O. Players alternate turns. A move is given by a two-digit string where the first digit represents the row and the second digit represents the column (e.g., "01" corresponds to row 0 and column 1).

After each valid move, check if the current player wins or if the game ends in a draw. A player wins if one of the following conditions holds:

  • All cells in one row are occupied by the player, i.e. \(b_{i,0} = b_{i,1} = b_{i,2} = \text{player}\).
  • All cells in one column are occupied by the player, i.e. \(b_{0,j} = b_{1,j} = b_{2,j} = \text{player}\).
  • All cells in the main diagonal are occupied by the player, i.e. \(b_{0,0} = b_{1,1} = b_{2,2} = \text{player}\).
  • All cells in the anti-diagonal are occupied by the player, i.e. \(b_{0,2} = b_{1,1} = b_{2,0} = \text{player}\).

If a move is invalid (e.g. out-of-bound indices or the cell is already occupied), ignore it and proceed to the next move. The game ends immediately when a player wins or if the board is completely filled without any winner, in which case the game is declared a draw.

inputFormat

The input consists of several lines. Each line contains a two-digit string representing a move. Moves are processed in the order they appear in the input.

outputFormat

Output a single line indicating the result of the game: either "Player X wins!", "Player O wins!", or "It's a draw!".

## sample
00
11
01
22
02
Player X wins!