CF3C.Tic-tac-toe
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:64MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
当然,大家对井字棋(tic-tac-toe)游戏都很熟悉。规则确实非常简单:两名玩家轮流在 3×3 的方格中画标记(一名玩家始终画“×”,另一名玩家画“○”);首位在水平、垂直或对角线上连成三个自己标记的玩家获胜,游戏随即结束。“×”玩家先手。若方格被填满,但既无三个“×”也无三个“○”构成所需连线,则判为平局。
现给出一个 3×3 的方格,每个格子为空、或已被“×”占据、或已被“○”占据。你需要判断:轮到哪位玩家(先手或后手)行动;或输出以下其中一种判定结果:
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”(一个英文句点、一个大写字母 X 或一个数字零)。
输出格式
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。
输入输出样例
输入#1
X0X .0. .X.
输出#1
second
输入解题思路,AI测评打分。不知道怎么写?