Codeforces Round #390 (Div. 2) B
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).
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.
Print single line: "YES" in case Ilya could have won by making single turn, and "NO" otherwise.
xx..
.oo.
x...
oox.
YES
x.ox
ox..
x.o.
oo.x
NO
x..x
..oo
o...
x.xo
YES
o.x.
o...
.x..
ooxx
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(水平和垂直,对角线)就算胜利
解法:暴力判断
#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的更多相关文章
- Codeforces Round #390 (Div. 2) D. Fedor and coupons(区间最大交集+优先队列)
http://codeforces.com/contest/754/problem/D 题意: 给定几组区间,找k组区间,使得它们的公共交集最大. 思路: 在k组区间中,它们的公共交集=k组区间中右端 ...
- 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 ...
- Codeforces Round #390 (Div. 2) A. Lesha and array splitting
http://codeforces.com/contest/754/problem/A 题意: 给出一串序列,现在要把这串序列分成多个序列,使得每一个序列的sum都不为0. 思路: 先统计一下不为0的 ...
- Codeforces Round #390 (Div. 2)
时隔一个月重返coding…… 期末复习了一个月也不亏 倒是都过了…… 就是计组61有点亏 复变68也太低了 其他都还好…… 假期做的第一场cf 三道题 还可以…… 最后room第三 standing ...
- Codeforces Round #390 (Div. 2) E(bitset优化)
题意就是一个给出2个字符矩阵,然后进行匹配,输出每个位置的匹配的结果 (超出的部分循环处理) 一种做法是使用fft,比较难写,所以没有写 这里使用一个暴力的做法,考虑到一共只出现26个字符 所以使用一 ...
- Codeforces Round #390 (Div. 2) A B C D
这是一场比较难的div2 ... 比赛的时候只出了AB A很有意思 给出n个数 要求随意的把相邻的数合并成任意多数 最后没有为0的数 输出合并区间个数与区间 可以想到0可以合到任何数上并不改变该数的性 ...
- Codeforces Round #390 (Div. 2) D
All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring s ...
- 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 ...
- Codeforces Round #390 (Div. 2) A+B+D!
A. Lesha and array splitting 水题模拟.(0:10) 题意:给你一个n个元素的数组,求能否把这个数组分成若干连续小段,使得每段的和不为0.如有多种解输出任意一个. 思路:搞 ...
随机推荐
- HDU5015 233 Matrix —— 矩阵快速幂
题目链接:https://vjudge.net/problem/HDU-5015 233 Matrix Time Limit: 10000/5000 MS (Java/Others) Memor ...
- # <center>merge表不可用的问题</center>
最近碰到了个很有意思的问题,值得一写 给merge表和基础表添加索引时发生了一个问题,不管是先给merge表加索引还是基础表加索引,如果表数据量大都会导致加索引期间对merge表的查询不可用,因为使用 ...
- jenkins页面不刷新,设置tomcat缓存
装jenkins的时候,部署后,访问jenkins页面,输入管理员密码后,出现jenkins页面停滞,看后台catlina日志,发现需要增加tomcat容器的cache,才能加载一些jar包,下面是设 ...
- 图片预览JavaScript方法
实现要点 ● 对于 Chrome.Firefox.IE10 使用 FileReader 来实现. ● 对于 IE6~9 使用滤镜 filter:progid:DXImageTransform.Mi ...
- 动态调试Android程序
最近好几天来一直在看动态调试.首先是这一篇(http://www.52pojie.cn/forum.php?mod=viewthread&tid=293648)里面介绍了多种IDA动态调试的情 ...
- vue中的 v-if VS v-show
相同点:都是动态显示DOM元素. 不同点:1.v-if是动态的向DOM树内添加或者删除DOM元素:v-show是通过设置DOM元素的display样式属性控制显隐: 2.v-if切换有一个局部编译/卸 ...
- 激活层和pooling的作用
激活层: 激活函数其中一个重要的作用是加入非线性因素的,将特征映射到高维的非线性区间进行解释,解决线性模型所不能解决的问题 pooling层: 1. invariance(不变性),这种不变性包括tr ...
- Markdown Reader 插件改造
Markdown Reader 是一款比较好用的浏览markdown文件的chrome插件 插件地址:https://chrome.google.com/webstore/detail/markdow ...
- 【218】◀▶ IDL 操作符号说明
参考:Operators —— 运算符 01 Relational_Operators 比较运算符. 02 Mathematical_Operators 数学运算符. 03 Logical ...
- Ubuntu解压windows下的.zip文件出现乱码的解决办法
乱码类似这样的:╫╩┴╧╖┤╤▌▓т╒╛╦┘╢╚│ 这个主要是因为zip文件对文件名的编码默认为当前环境的locale,如在windows下压缩的zip文件,在linux下其中的中文名便会乱码.这是z ...