The game tic-tac-toe is played on a grid. Two players place cross (X
) and nought (O
) alternatively. The game ends whenever a player can make a line of 3 of their mark vertically, horizontally, or diagonally; or all slots are occupied.
O | X | |
X | X | O |
O |
In this problem, you are given a snapshot of a game and you need to verify if it is valid. You can assume that the first mark to be placed is always a cross.
Input Specification
The first input is a number specifying the number of test cases . For each test case, characters on each line are used to denote a snapshot, each containing only .
(period, representing an empty slot), X
, and O
. The first 3 characters are the contents of the first row, the next 3 are for the second row, etc. For example, the snapshot of the example is represented as follows:
O.XXXO..O
Output Specification
For each test case, output yes
if the snapshot is valid; no
, otherwise.
Sample Input
4
.........
..O...X..
..OO..X..
OOOXXX...
Sample Output
yes
yes
no
no
Comments
What does CCCHK stand for?
Canadian Computing Competition Hong Kong
I'm pretty sure "valid" as if it's possible to reach this state from the beginning... not that hard to understand
Does "valid" just mean that (1) no more than one person has won and (2) there are not more O's than X's?
and also, when "O" is win, number of "X" cannot be greater than "O": "XO. XOX .OX" is invalid
Bump, Clarification on valid?