ZCMU—1891
来源:互联网 发布:李健 快乐男声 知乎 编辑:程序博客网 时间:2024/05/22 12:31
1891: kotomi and game
Time Limit: 1 Sec Memory Limit: 128 MB[Submit][Status][Web Board]
Description
kotomi最近有点累,于是想玩个游戏。
kotomi九宫格玩腻了,于是想玩十六宫格。
只要满足横或竖或对角线上有3个'x'就获胜。
只能画在'.'上。
Input
输入第一行包含一个整数T(1 <= T <= 10)
接下来包含4*4矩阵,矩阵只包含'x','.','o'.
Output
如果能获胜则输出"yes",否则输出"no"
Sample Input
4
xx..
.oo.
x...
oox.
x.ox
ox..
x.o.
oo.x
x..x
..oo
o...
x.xo
o.x.
o...
.x..
ooxx
Sample Output
yes
no
yes
no
【分析】
暴力模拟一下就好了...对每个'.'寻找它的周围能不能组成3个'x',情况考虑完全就可以了,要注意有一种情况是'.'在中间比如,'x.x'
【代码】
#include <stdio.h> char a[10][10]; int find(int i,int j){ if (a[i+1][j]=='x' && a[i+2][j]=='x') return 1; if (a[i][j+1]=='x' && a[i][j+2]=='x') return 1; if (i>2 && a[i-1][j]=='x' && a[i-2][j]=='x') return 1; if (j>2 && a[i][j-1]=='x' && a[i][j-2]=='x') return 1; if (a[i-1][j]=='x' && a[i+1][j]=='x') return 1; if (a[i][j-1]=='x' && a[i][j+1]=='x') return 1; if (a[i-1][j+1]=='x' && a[i+1][j-1]=='x') return 1; if (a[i-1][j-1]=='x' && a[i+1][j+1]=='x') return 1; if (i>2 && j>2 && a[i-1][j-1]=='x' && a[i-2][j-2]=='x') return 1; if (a[i+1][j+1]=='x' && a[i+2][j+2]=='x') return 1; if (j>2 && a[i+1][j-1]=='x' && a[i+2][j-2]=='x') return 1; if (i>2 && a[i-1][j+1]=='x' && a[i-2][j+2]=='x') return 1; return 0;} int main(){ int pp;scanf("%d",&pp); char f[10]; for (int i=0;i<7;i++) a[i][6]=a[6][i]=a[i][0]=a[i][5]=a[0][i]=a[5][i]='o'; while (pp--) { getchar(); for (int i=1;i<5;i++) { scanf("%s",f); for (int j=0;j<4;j++) a[i][j+1]=f[j]; } for (int i=1;i<5;i++) for (int j=1;j<5;j++) if (a[i][j]=='.') if (find(i,j)) { printf("yes\n"); goto out; } printf("no\n"); out:; } return 0;}
0 0
- ZCMU—1891
- ZCMU—1678
- ZCMU—1605
- ZCMU—1067
- ZCMU—1607
- ZCMU—1069
- ZCMU—1611
- ZCMU—1606
- ZCMU—1774
- ZCMU—1766
- ZCMU—1752
- ZCMU—1724
- ZCMU—1623
- ZCMU—1689
- ZCMU—1667
- ZCMU—1639
- ZCMU—1668
- ZCMU—1540
- Privacy Policy
- 关于css的继承
- 字符串匹配的KMP算法
- 玲珑学院OJ 1020 Grand Master【思维+并查集】
- Python开发环境
- ZCMU—1891
- iOS10或iphone7偶然不能下载app 但过段时间又好了
- pre自动换行输出
- (六)ArcGIS API For Javascript之查询功能
- 自我介绍:历史背景-从学校到工作
- 史上最简单的在 Yii2.0 中将数据导出成 Excel
- 在Windows 10系统下安装JDK
- 如何实现“猜你喜欢”功能
- 修改linux文件权限命令:chmod