1000ms 65536K
Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 grid (one player always draws crosses, the other — noughts). The player who succeeds first in placing three of his marks in a horizontal, vertical or diagonal line wins, and the game is finished. The player who draws crosses goes first. If the grid is filled, but neither Xs, nor 0s form the required line, a draw is announced.
每个人都熟悉一字棋游戏。规则确实很简单。两名玩家轮流在3 × 3的格子中标记方格(一名玩家画叉字,另一名玩家总是画圈)。第一个在水平、垂直或对角线上画出三个对应图形的玩家获胜,游戏结束。画叉的玩家先走。如果网格被填满,但是x和o都没有出现在所需的直线上,那么就宣布平局。
You are given a 3 × 3 grid, each grid cell is empty, or occupied by a cross or a nought. You have to find the player (first or second), whose turn is next, or print one of the verdicts below:
给你一个3 × 3的网格,每个网格单元格都是空的,或者被一个叉或零所占据。你必须找到下一个轮到谁的玩家(第一名或第二名),或者输出以下结论之一:
The input consists of three lines, each of the lines contains characters ".", "X" or "0" (a period, a capital letter X, or a digit zero).
输入共三行,每行包含字符“。”、“X”或“0”(句点、大写字母X或数字0)。
Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.
输出六结果中的一个:第一,第二,非法,第一玩家赢,第二玩家赢或平局。
X0X .0. .X.
second