原题链接--
https://acs.jxnu.edu.cn/problem/CF3Chttps://acs.jxnu.edu.cn/problem/CF3C
Tic-tac-toe
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.
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.
译文: 当然,每个人都很熟悉井字游戏。它的规则实际上非常简单。两个玩家轮流在3x3的网格中标记单元格(一个玩家画叉,一个玩家画圈)。第一个玩家的三个标记在一个水平、垂直或对角线上的获胜,游戏结束。画叉的玩家先走。如果网格被填满,但是x和0都没有连成线,就宣布平局。
你是被给了一个3X3的网格,每一个网格单元都是空的,用叉或圈来填满。你必须找到下一个轮到谁的玩家(第一个或第二个) ,或者打印下面的判决之一:
illegalー如果给定的棋盘布局在一个有效的游戏中不能出现;
the first player won — 如果给定的棋盘布局中第一个玩家获胜;
the second player won — 如果给定的棋盘布局中第二个玩家获胜;
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).
译文:输入有三行,每一行都包含字符".", "X" 或 "0"(一个句号,一个大写字母或是一个数字0)。
输出:
Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.
译文:打印六个判决之一:first, second, illegal, the first player won, the second player won或 draw.
样例输入:
X0X .0. .X.
样例输出:
second