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).

Input

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.

Output

Print single line: "YES" in case Ilya could have won by making single turn, and "NO" otherwise.

Examples
input
xx..
.oo.
x...
oox.
output
YES
input
x.ox
ox..
x.o.
oo.x
output
NO
input
x..x
..oo
o...
x.xo
output
YES
input
o.x.
o...
.x..
ooxx
output
NO
Note

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(水平和垂直,对角线)就算胜利

解法:暴力判断

 #include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
const int maxn=1e5;
char Mp[][];
int solve(){
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(Mp[i][j]=='x'&&Mp[i][j+]=='x'&&Mp[i][j+]=='x'&&j+<=){
return ;
}
}
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(Mp[i][j]=='x'&&Mp[i+][j]=='x'&&Mp[i+][j]=='x'&&i+<=){
return ;
}
}
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(Mp[i][j]=='x'&&Mp[i+][j+]=='x'&&Mp[i+][j+]=='x'&&i+<=&&j+<=){
return ;
}
}
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(Mp[i][j]=='x'&&Mp[i+][j-]=='x'&&Mp[i+][j-]=='x'&&i+<=&&j->=){
return ;
}
}
}
return ;
}
int main(){
for(int i=;i<=;i++){
for(int j=;j<=;j++){
cin>>Mp[i][j];
}
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(Mp[i][j]=='.'){
Mp[i][j]='x';
if(solve()){
cout<<"YES"<<endl;
return ;
}
Mp[i][j]='.';
}
}
}
cout<<"NO"<<endl;
return ;
}

Codeforces Round #390 (Div. 2) B的更多相关文章

  1. Codeforces Round #390 (Div. 2) D. Fedor and coupons(区间最大交集+优先队列)

    http://codeforces.com/contest/754/problem/D 题意: 给定几组区间,找k组区间,使得它们的公共交集最大. 思路: 在k组区间中,它们的公共交集=k组区间中右端 ...

  2. Codeforces Round #390 (Div. 2) C. Vladik and chat(dp)

    http://codeforces.com/contest/754/problem/C C. Vladik and chat time limit per test 2 seconds memory ...

  3. Codeforces Round #390 (Div. 2) A. Lesha and array splitting

    http://codeforces.com/contest/754/problem/A 题意: 给出一串序列,现在要把这串序列分成多个序列,使得每一个序列的sum都不为0. 思路: 先统计一下不为0的 ...

  4. Codeforces Round #390 (Div. 2)

    时隔一个月重返coding…… 期末复习了一个月也不亏 倒是都过了…… 就是计组61有点亏 复变68也太低了 其他都还好…… 假期做的第一场cf 三道题 还可以…… 最后room第三 standing ...

  5. Codeforces Round #390 (Div. 2) E(bitset优化)

    题意就是一个给出2个字符矩阵,然后进行匹配,输出每个位置的匹配的结果 (超出的部分循环处理) 一种做法是使用fft,比较难写,所以没有写 这里使用一个暴力的做法,考虑到一共只出现26个字符 所以使用一 ...

  6. Codeforces Round #390 (Div. 2) A B C D

    这是一场比较难的div2 ... 比赛的时候只出了AB A很有意思 给出n个数 要求随意的把相邻的数合并成任意多数 最后没有为0的数 输出合并区间个数与区间 可以想到0可以合到任何数上并不改变该数的性 ...

  7. Codeforces Round #390 (Div. 2) D

    All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring s ...

  8. Codeforces Round #390 (Div. 2) A

    One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into sev ...

  9. Codeforces Round #390 (Div. 2) A+B+D!

    A. Lesha and array splitting 水题模拟.(0:10) 题意:给你一个n个元素的数组,求能否把这个数组分成若干连续小段,使得每段的和不为0.如有多种解输出任意一个. 思路:搞 ...

随机推荐

  1. VK Cup 2012 Qualification Round 1 E. Phone Talks —— DP

    题目链接:http://codeforces.com/contest/158/problem/E E. Phone Talks time limit per test 3 seconds memory ...

  2. HDU1102 Constructing Roads —— 最小生成树

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1102 题解: 纯最小生成树,只是有些边已经确定了要加入生成树中,特殊处理一下这些边就可以了. krus ...

  3. Idea中的插件-列出Java Bean的所有set方法

    插件的git 地址: https://github.com/yoke233/genSets 将插件jar导入idea中,使用方式是对象后加.allset,然后回车.

  4. windows下使用emacs+plink远程编辑erlang文件

    1)plink.exe属于putty套件, 注册到环境变量;emacs的bin目录也要注册到环境变量中; 2)在.emacs中增加如下: (require 'tramp)(setq tramp-def ...

  5. ROM的分类

    转载自:http://www.ic37.com/htm_tech/2012-5/82774_23811.htm ROM(只读存储器)按其内容写入方式,一般分为3种:固定内容ROM:可一次编程PROM: ...

  6. C++之log4cpp库的使用

    log4..简介 log4..是基于log4j的一系列的c++移植版本,使用了log4j的模式结构,目前主要有以下几个版本: 1. log4cxx, 目前是到0.10.0版,Apache下的孵化项目, ...

  7. HDU2546(01背包变形)

    饭卡 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...

  8. mysql函数之七:replace() MySQL批量替换指定字段字符串

    mysql replace实例说明: UPDATE tb1 SET f1=REPLACE(f1, 'abc', 'def'); REPLACE(str,from_str,to_str) 在字符串 st ...

  9. MVC错误:查询的结果不能枚举多次

    应用程序中的服务器错误. 查询的结果不能枚举多次. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息. 异常详细信息: S ...

  10. Windows服务卸载服务窗口仍显示的问题

    关于Windows服务通过命令卸载后, 打开服务窗口,服务还有显示,只是状态改为了禁用,运行停止.那么我们怎么解决呢, 不要心慌,打开你的任务管理器,查看服务所用的exe程序是否还在运行,若有的话,便 ...