#P14017. [ICPC 2024 Nanjing R] 棋字井
[ICPC 2024 Nanjing R] 棋字井
Description
Alice and Bob are playing Toe-Tac-Tics on boards with rows and columns. Some cells on the boards are initially empty, while the others already contain some marks. Alice moves first, and they take turns to select a board and put their marks into an empty cell on that board. Alice's mark is x and Bob's mark is o.
Each player must make sure that no three same marks are in any row, column, or diagonal on any board after his/her move. The player who cannot make a valid move on their turn loses, and the other player wins.
Given the initial state of the boards, you need to determine who wins, assuming both players play optimally for victory.
Input Format
There are multiple test cases. The first line of the input contains an integer indicating the number of test cases. For each test case:
The first line contains an integer (), indicating the number of boards in the game.
Then boards of size follow. For each board:
- There will first be an empty line if it is not the first board.
- For the following three lines, the -th line contains a string of length consisting of characters
x,o, and., describing a board of size . Let be the cell on the -th row and the -th column. Ifxthen cell contains a markx; ifothen cell contains a marko; if.then cell is empty.
It is guaranteed that no three same marks are in any row, column, or diagonal on any board. It is also guaranteed that the sum of for all test cases does not exceed .
Output Format
For each test case, output if Alice wins the game, or if Bob wins the game.
4
1
...
...
...
1
...
oo.
oo.
2
...
oo.
oo.
...
xx.
xx.
2
..x
xo.
...
xo.
o..
.x.
Alice
Alice
Bob
Bob
京公网安备 11011102002149号