描述:
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.
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:
- illegal — if the given board layout can't appear during a valid game;
- the first player won — if in the given board layout the first player has just won;
- the second player won — if in the given board layout the second player has just won;
- draw — if the given board layout has just let to a draw.
输入:
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).
输出:
Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.
样例输入:
X0X .0. .X.
样例输出:
second
描述:
当然,每个人都熟悉一字棋游戏。规则确实很简单。两名玩家轮流在3x3的网格(一个人总是画叉,另一个人画零)中标记方格。先在水平、垂直或对角线上画出三个他的标记的玩家获胜,游戏结束。画叉的玩家先画。如果网格被填满,但是X和0都不在要求的直线上,则宣布平局。
现提供给你一个3x3的网格,每个网格单元是空的,或者被一个叉或零占据。你需要去寻找玩家(第一个或者第二个),下一个轮到谁,或者输出以下的结果:
非法的——如果给定的棋盘布局不能出现在一个有效的游戏。
第一个玩家获胜——如果在给定的棋盘布局中第一个玩家刚好获胜。
第二个玩家获胜——如果在给定的棋盘布局中第二个玩家刚好获胜。
平局——如果在给定的棋盘布局中刚刚好是一个平局。
输入:
输入由三行组成,每一行包括字符 ".", "X" or "0"(句点,大写字母X,或者数字零)。
输出:
输出六种结果中的一种:第一,第二,非法的,第一个玩家获胜,第二个玩家获胜或者平局。
样例输入:
X0X .0. .X.
样例输出:
second
题目地址链接:Problem - C - Codeforces