CodeForces 754B Ilya and tic-tac-toe game
来源:互联网 发布:c语言入门经典txt下载 编辑:程序博客网 时间:2024/05/27 03:29
题目链接:http://codeforces.com/contest/754/problem/B
题意:给你一个4x4的棋盘,然后上面有一些棋子,x和o,x是先手的,如果有三个一样的符号连在一起那一方就胜利,问你x能否胜利,能就输出YES,否则输出NO
解析:其实就是那个xo棋,只是棋盘变大了,我一开始以为会复杂,所以懒得想直接判断先手第一步能否胜利,不能就直接输出NO了,因为我猜两边都赢不了的话,那就只能走平局了,毕竟我玩3x3的时候多半都是平局,代码有点丑。
#include <bits/stdc++.h>using namespace std;const int maxn = 105;char a[10][10];bool judge(char x){ for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { if(a[i][j]==x) { if(a[i+1][j]==x && (a[i+2][j]=='.' || a[i-1][j]=='.')) return true; if(a[i][j+1]==x && (a[i][j+2]=='.' || a[i][j-1]=='.')) return true; if(a[i+1][j+1]==x && (a[i+2][j+2]=='.' || a[i-1][j-1]=='.')) return true; if(a[i+1][j-1]==x && (a[i+2][j-2]=='.' || a[i-1][j+1]=='.')) return true; if(a[i+2][j]==x && a[i+1][j]=='.') return true; if(a[i][j+2]==x && a[i][j+1]=='.') return true; if(a[i+2][j+2]==x && a[i+1][j+1]=='.') return true; if(a[i+2][j-2]==x && a[i+1][j-1]=='.') return true; } } } return false;}int main(void){ for(int i=0;i<4;i++) scanf("%s",a[i]); if(judge('x')) puts("YES"); else puts("NO"); return 0;}
0 0
- 【Codeforces 754 B Ilya and tic-tac-toe game】
- 【codeforces 754B】 Ilya and tic-tac-toe game
- codeforces 754 B Ilya and tic-tac-toe game
- CodeForces 754B Ilya and tic-tac-toe game
- B. Ilya and tic-tac-toe game
- Cdoeforces 754 B - Ilya and tic-tac-toe game
- 754B Ilya and tic-tac-toe game
- 754B. Ilya and tic-tac-toe game
- Codeforces-754B-Ilya and tic-tac-toe game(简单模拟判断)
- Codeforces Round #390(Div. 2)B. Ilya and tic-tac-toe game【模拟】
- Codeforces Round #390 (Div. 2)-B Ilya and tic-tac-toe game(模拟)
- Codeforces Round #390 (Div. 2) B. Ilya and tic-tac-toe game(dfs)
- Codeforces Round #390 (Div. 2)B Ilya and tic-tac-toe game
- Codeforces #390 (Div. 2) B. Ilya and tic-tac-toe game ( DFS
- 2017寒假集训-小题训练1:F - Ilya and tic-tac-toe game
- 001 tic-tac-toe game
- [Codeforces]C. Tic-tac-toe
- uva 11623 - Tic Tac Toe(game)
- 矩阵逆时针旋转90度
- Handler looper meessage messagequeue 之间的关系
- Mysql
- MyEclipse 2016 破解详细过程
- qqtf支付逻辑修改
- CodeForces 754B Ilya and tic-tac-toe game
- Hibernate连接sqlite使用相对路径(src)
- 走进数据结构之排序(七)---归并排序
- CodeForces
- 蓝桥杯之方格填数
- 课堂笔记_ 光线跟踪原理
- C语言实现一个队列
- 开始安卓技术学习之旅
- 【学习笔记19】java面向对象-包