CF754B.Ilya and tic-tac-toe game
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game when they left it. Determine whether Ilya could have won the game by making single turn or not.
The rules of tic-tac-toe on the 4 × 4 field are as follows. Before the first turn all the field cells are empty. The two players take turns placing their signs into empty cells (the first player places Xs, the second player places Os). The player who places Xs goes first, the another one goes second. The winner is the player who first gets three of his signs in a row next to each other (horizontal, vertical or diagonal).
伊利亚是 4 × 4 棋盘井字棋(Tic-Tac-Toe)的一名经验丰富的玩家。他总是先手,且始终使用 X。今天他与朋友阿尔谢尼进行了多局对弈。两人玩得十分疲惫,未能完成最后一局。他们离开时,轮到伊利亚落子。请判断:伊利亚是否可以通过仅下一步就赢得该局游戏?
4 × 4 棋盘井字棋的规则如下:初始时,棋盘上所有格子均为空;两名玩家轮流将各自的棋子放入空格中(先手玩家放置 X,后手玩家放置 O),其中 X 方先行,O 方后行;首位在水平、竖直或对角线上连续获得三个己方棋子的玩家获胜。
输入格式
The tic-tac-toe position is given in four lines.
Each of these lines contains four characters. Each character is '.' (empty cell), 'x' (lowercase English letter x), or 'o' (lowercase English letter o). It is guaranteed that the position is reachable playing tic-tac-toe, and it is Ilya's turn now (in particular, it means that the game is not finished). It is possible that all the cells are empty, it means that the friends left without making single turn.
井字棋局面以四行给出。
每行包含四个字符。每个字符为 '.'(空格)、'x'(小写英文字母 x)或 'o'(小写英文字母 o)。保证该局面是通过合法的井字棋对局可达的,且当前轮到 Ilya 行棋(特别地,这意味着游戏尚未结束)。所有格子均为空的情况是可能的,这表示两位朋友尚未进行任何一步棋。
输出格式
Print single line: "YES" in case Ilya could have won by making single turn, and "NO" otherwise.
输出单行:如果伊利亚通过一次操作即可获胜,则输出“YES”,否则输出“NO”。
输入输出样例
输入#1
xx.. .oo. x... oox.
输出#1
YES
输入#2
x.ox ox.. x.o. oo.x
输出#2
NO
输入#3
x..x ..oo o... x.xo
输出#3
YES
输入#4
o.x. o... .x.. ooxx
输出#4
NO
说明/提示
In the first example Ilya had two winning moves: to the empty cell in the left column and to the leftmost empty cell in the first row.
In the second example it wasn't possible to win by making single turn.
In the third example Ilya could have won by placing X in the last row between two existing Xs.
In the fourth example it wasn't possible to win by making single turn.
在第一个例子中,伊利亚有两个制胜着法:左侧一列中的空格,以及第一行中最左侧的空格。
在第二个例子中,无法通过一次落子获胜。
在第三个例子中,伊利亚可以在最后一行的两个已有 X 之间放置一个 X 来获胜。
在第四个例子中,无法通过一次落子获胜。
输入解题思路,AI测评打分。不知道怎么写?