BdOI 2013 National Problem 2

Discuss everything related to IOI here. For more general or advanced topics use CS forum.

Moderators:Labib, bristy1588

User avatar
bristy1588
Posts:92
Joined:Sun Jun 19, 2011 10:31 am
BdOI 2013 National Problem 2

Unread post by bristy1588 » Tue Jan 14, 2014 11:20 pm

We all know the popular game tic-tac-toe. In this game we play in a three by three grid and
put $"X" $ or $"O"$ in the cells. If the first player can put three consecutive $X's$ in a row, column or
diagonal then he wins. Same goes for the second player, only he needs to put $O's $. Given a
configuration of tic-tac-toe board, you are playing with $"X"$. Find if you can win by giving a
single move in the current board. It is guaranteed that the board is not yet won by anybody.
It is also guaranteed that, the board is a valid game position.

INPUT
First line contains $T (T < 2500)$, number of cases. Then three lines for each case. Each line
will contain three characters. These characters can be: $"X" $ (Your move), $"O" $ (Opponent
move) or $"." $(Empty cell). These three lines denote a board position.

OUTPUT
For each test case, print the test case number starting from $1$ and $"YES"$, if you can win by
giving a single move, $"NO"$, otherwise.


Sample Input

Code: Select all

3
XXO
...
OOX
X.O
OOX
..X
O..
.X.
.OX
Sample Output

Code: Select all

Case 1: YES
Case 2: NO
Case 3: NO
Bristy Sikder

Post Reply