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.如有多种解输出任意一个. 思路:搞 ...
随机推荐
- Appium——详解Appium server capabilities
appium server capabilities来告诉appium,如何运行自动化测试,因此需要详细了解. 官方文档:http://appium.io/slate/en/master/?rub ...
- RobotFramework教程使用笔记——web自动化测试弹窗处理
在web自动化测试中会遇到各种弹出框,在selenium中有对这些弹出框的处理. 弹出框一般有这么几类: 1.普通的弹出窗口,如果是可以定位的,直接定位到窗口,然后进行相应的操作. 2.如果是浏览器系 ...
- 灵活使用rewrite
Nginx提供的全局变量或自己设置的变量,结合正则表达式和标志位实现url重写以及重定向.rewrite只能放在server{},location{},if{}中,并且只能对域名后边的除去传递的参数外 ...
- runtime之实现对象序列化
/* iOS序列化,将对象转成二进制,保存到本地 */ 定义一个对象,让它实现NSCoding协议,保证对象的编码和解码,person有三个属性 @interface Person : NSObjec ...
- ibatis 优点,未完版
iBatis是Apache的一个开源项目,一个O/R Mapping(???)解决方案,iBatis最大的特点就是小巧,上手很快,如果不需要太多复杂的功能,ibatis是能满足你得要求又足够灵活的最简 ...
- PHP中的关系判断和注释
== 只判断内容,不判断类型=== 全等于,即判断内容,又判断类型 != 不等于,只判断内容,不判断类型 !== 全不等于,即判断内容,又判断类型
- 转,如果linux不能用yum安装asterisk时,可以库参照以下办法添加asterisk仓库
LinuxCentOSRedHat Installing a binary distribution of Asterisk makes it easier to maintain your syst ...
- 51Nod - 1821:最优集合 (求第一个不能被表示为多个数的和的数)(不错的动脑题)
一个集合S的优美值定义为:最大的x,满足对于任意i∈1,x1,x,都存在一个S的子集S',使得S'中元素之和为i. 给定n个集合,对于每一次询问,指定一个集合S1和一个集合S2,以及一个数k,要求选择 ...
- Java笔记(九)
网络编程: UDP传输: (UdpSend发送端)通过UDP传输方式,将一段文字数据发送出去: (1)建立udpsocket服务 (2)提供数据,并将数据封装到数据包中 (3)通过socket服务的发 ...
- LiveCD、LiveDVD和BinDVD区别在哪里
本文转载自: http://www.kankanews.com/ICkengine/archives/86968.shtml 1.CentOS系统镜像有两个,安装系统只用到第一个镜像即CentOS-6 ...