Codeforces 3C Tic-tac-toe
来源:互联网 发布:sql identity 编辑:程序博客网 时间:2024/05/19 16:47
English
Desc
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.
Input
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).
Output
Print one of the six verdicts: first, second, illegal, the first player won, the second player won or draw.
Examples
input
X0X.0..X.
output
second
中文
简介
当然,每个人都熟悉tic-tac-toe游戏。规则很简单。两名球员轮流在3×3格网格中标注图案(first总是画X,second球员则是O)。第一次在水平,垂直或对角线上放置三个标记的人就赢了,游戏结束。画X的玩家先行。如果网格已经填充,但是X和0都不会形成所需的行,则会输出一个图。
给你一个3×3的网格,每个网格单元都是空的,或被十字架还是一个空的。你必须找到玩家(第一个或第二个),其次是下一个,或打印下面的一个裁决:
- illegal–如果给定的棋盘布局在有效的游戏中不能出现
- the first player won —如果在给定的棋盘布局中,第一名玩家刚刚赢了;
- the second player won — 如果在给定的棋盘布局中,第二名玩家刚刚赢了;
- draw — 绘制 - 如果给定的板布局刚刚让一幅画。
输入格式
输入由三行组成,每行包含字符“ . ”,“ X ”或“ 0 ”(一个句点,大写字母X或数字零)。
输出格式
打印六个输出之一:first,second,illegal, the first player won ,the second player won ,draw
测试用例
测试输入
X0X.0..X.
测试输出
second
- codeforces 3C. Tic-tac-toe
- codeforces 3C Tic-tac-toe
- Codeforces 3C. Tic-tac-toe
- Codeforces 3 C. Tic-tac-toe
- CodeForces 3C-Tic-tac-toe
- Codeforces 3C Tic-tac-toe
- [Codeforces]C. Tic-tac-toe
- Codeforces Beta Round #3C. Tic-tac-toe
- Codeforces Beta Round #3 C. Tic-tac-toe
- codeforces 3C Tic-tac-toe (想法题)
- CodeForces 3C Tic-tac-toe 井字棋盘游戏
- CodeForces 3C---Tic-tac-toe--思维题
- codeforces - 3C - Tic-tac-toe(模拟)
- Codeforces Beta Round #3-C. Tic-tac-toe
- CodeForces 3C Tic-tac-toe(模拟)
- C - Tic-tac-toe
- CF 3C Tic-tac-toe
- CF 3C Tic-tac-toe
- android菜鸟练手小项目之自定义日历,涵盖LitePal数据库,极光推送(一)
- 设计模式拾荒之命令模式( Command Pattern )
- 表格选择框----全选的动态勾选
- Java Switch()可以用的类型
- 57. Insert Interval
- Codeforces 3C Tic-tac-toe
- pom文件解析
- java RandomAccessFile随机读写流
- Java事务处理全解析(二)—— 失败的案例
- C++ 静态单例
- [设计模式]23种设计模式分类和设计原则
- 最新版PhpStorm 2017激活办法
- proj.4编译 win10 vs2015
- Java事务处理全解析(三)—— 丑陋的案例