14285 - Gaming Battle (Part I: Tic-tac-toe)   

Description

Your task is to develop a program that supports the Tic-tac-toe game.

  • Tic-tac-toe rules
    • The goal is to be the first to get three of your marks in a row (horizontally, vertically, or diagonally).
    • Players take turns placing their symbol (either X or O) in an empty square on a 3x3 grid. 
    • The first player to align three of their symbols in a row on the grid wins the game.
    • If all nine squares are filled and no player has three marks in a row, the game is a draw.

This is a partial judge problem. Please review the provided code and refer to the sections labeled "TODO" in the function.h file for further details, and using C++17 to submit your solution.

 

Input

The first line of the input contains an integer N, representing the number of test cases. (1 ≤ N ≤ 5 × 104)

Each of the following N lines represents a test case. Each line records a game session, detailing every move made by the players. The game may conclude early if one player wins. The game records are formatted as follows (- - represents the end of each test case):

<player1_symbol> <Move> <player2_symbol> <Move> ... <player1or2_symbol> <Move> - -

We guarantee that players will not play out of turn or make illegal moves, such as placing pieces on already occupied spaces.

The player's symbol will be either "O" or "X". The move format for Tic-tac-toe is x/y where "x" represents the row and "y" represents the column, indicating the placement of a piece on the board at position board[x][y].

 

Output

Refer to the sample output provided.

If a game concludes without a winner after all moves in each testcase, output "Tie". Otherwise, tell the winner of the game. Additionally, display the status of the board at the end of the game. Please ensure to leave an empty line in the output at the end of each test case.

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

14285.cpp

Partial Judge Header

14285.h

Tags




Discuss