A7733 | Tic-tac-toe
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
当然,大家都熟悉井字棋游戏。 这些规则确实很简单。 两个玩家A、B轮流在3x3的方格的单元格中画符号(玩家A总是画“X”,玩家B总是画“0”)。 首先在水平、垂直或对角线上出现3个相同的符号的玩家获胜,比赛结束。 玩家A总是为先手。 如果3x3的方格被填满,但是在所有水平、垂直或对角线上均未出现3个相同的符号,宣布平局。
给你一个3*3的方格,每个单元格是“.”(空白),“X”或“0”。 你必须输出以下内容之一:
玩家A走棋(输出“first”)——如果出现给定的状态后,下一步为玩家A走棋。
玩家B走棋(输出“second”)——如果出现给定的状态后,下一步为玩家B走棋。
非法(输出“illegal”)——如果给定的状态无法在正常游戏过程中出现。
玩家A胜利(输出“the first player won”)——如果给定的状态中玩家A胜利。
玩家B胜利(输出“the second player won”)——如果给定的状态中玩家B胜利。
平局(输出“draw”)——如果给定的状态是平局。
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.
当然,大家都熟悉井字棋游戏。 这些规则确实很简单。 两个玩家A、B轮流在3x3的方格的单元格中画符号(玩家A总是画“X”,玩家B总是画“0”)。 首先在水平、垂直或对角线上出现3个相同的符号的玩家获胜,比赛结束。 玩家A总是为先手。 如果3x3的方格被填满,但是在所有水平、垂直或对角线上均未出现3个相同的符号,宣布平局。
给你一个3*3的方格,每个单元格是“.”(空白),“X”或“0”。 你必须输出以下内容之一:
玩家A走棋(输出“first”)——如果出现给定的状态后,下一步为玩家A走棋。
玩家B走棋(输出“second”)——如果出现给定的状态后,下一步为玩家B走棋。
非法(输出“illegal”)——如果给定的状态无法在正常游戏过程中出现。
玩家A胜利(输出“the first player won”)——如果给定的状态中玩家A胜利。
玩家B胜利(输出“the second player won”)——如果给定的状态中玩家B胜利。
平局(输出“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.
输入输出样例
输入 #1
X0X .0. .X.
输出 #1
second
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?