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.如有多种解输出任意一个. 思路:搞 ...
随机推荐
- HDU5968 异或密码 —— 二分 + 边界的细节处理
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5968 异或密码 Time Limit: 2000/1000 MS (Java/Others) M ...
- 坡道定点停车30cm
坡道定点停车与起步是科目二五项必考之一,想要顺利通过该项考试,学员需要掌握两个要点,一个是车身距离右侧边线30cm以内的距离,一个是定点时机.本期,元贝小编先和大家分享半坡起步右边30公分怎么看. ...
- tomcat启动项目被重新加载,导致资源初始化两遍
之前没有遇到过这个问题,配了三天的项目了,惊人啊!!!各种怪问题全被我赶上了.真有种骂人的冲动. tomcat启动项目时,项目资源被加载两遍. 原因:配置虚拟目录导致,项目被重新加载. <Hos ...
- html5--5-7 绘制圆/弧
html5--5-7 绘制圆/弧 学习要点 掌握arc() 方法创建圆弧/曲线(用于创建圆或部分圆) 矩形的绘制方法 rect(x,y,w,h)创建一个矩形 strokeRect(x,y,w,hx,y ...
- 搜索算法 pots
题目链接 点击打开链接 Pots Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u Su ...
- centos 安装配置kettle
安装JDK1.8: step1 下载JDK1.8 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133 ...
- web数据存储
数据的存储必然是任何网站必须经历的事,我们可以将数据存放在不同地方,数据库.文件.内存.程序本身.cookie,session中都可以,但是只要需要持久化保留的数据,那么最终肯定还是落在磁盘之上的,我 ...
- K个联通块
题意: 有一张无重边的无向图, 求有多少个边集,使得删掉边集里的边后,图里恰好有K个联通块. 解法: 考虑dp,$h(i,S)$表示有$i$个联通块,点集为$S$的图的个数,$g(S)$表示点集为S的 ...
- python数据分析笔记中panda(2)
1 将手机号码分开为运营商,地区和号码段 from pandas import read_csv; df = read_csv("H:\\pythonCode\\4.6\\data.csv& ...
- 爬虫代码实现四:采用Hbase存储爬虫数据(2)
导入hbase的jar包,在maven仓库找:进入http://mavenrepository.com/,输入hbase client,选择apache hbase client, 点击进入,选择 点 ...