Educational Codeforces Round 25 B. Five-In-a-Row
来源:互联网 发布:java防止sql注入转义 编辑:程序博客网 时间:2024/05/17 22:20
题目链接:Five-In-a-Row
题目大意:现在有X和O两种代表黑方和白方的两种棋子,.代表空白格,可以下,当前是黑方的下棋,问黑方这一次能不能马上赢掉,五子棋规则
题目思路:按照五子棋下棋方式去模拟就好了
#include <bits/stdc++.h>using namespace std;char mp[15][15];bool check(int x,int y){ int cnt = 0,xx = x,yy = y; xx--; while(xx > 0){ if(mp[xx][yy] == 'X') cnt++,xx--; else break; } xx = x+1; while(xx < 11){ if(mp[xx][yy] == 'X') cnt++,xx++; else break; } if(cnt >= 4) return true; cnt = 0;xx = x;yy = y; yy--; while(yy > 0){ if(mp[xx][yy] == 'X') cnt++,yy--; else break; } yy = y+1; while(yy < 11){ if(mp[xx][yy] == 'X') cnt++,yy++; else break; } if(cnt >= 4) return true; cnt = 0;xx = x;yy = y; yy--;xx--; while(yy > 0&&xx > 0){ if(mp[xx][yy] == 'X') cnt++,yy--,xx--; else break; } yy = y+1;xx = x+1; while(yy < 11&&xx < 11){ if(mp[xx][yy] == 'X') cnt++,yy++,xx++; else break; } if(cnt >= 4) return true; cnt = 0;xx = x;yy = y; yy--;xx++; while(yy > 0&&xx < 11){ if(mp[xx][yy] == 'X') cnt++,yy--,xx++; else break; } yy = y+1;xx = x-1; while(yy < 11&&xx > 0){ if(mp[xx][yy] == 'X') cnt++,yy++,xx--; else break; } if(cnt >= 4) return true; return false;}int main(){ for(int i = 1;i <= 10;i++) for(int j = 1;j <= 10;j++) cin>>mp[i][j]; for(int i = 1;i <= 10;i++){ for(int j = 1;j <= 10;j++){ if(mp[i][j] == '.'){ if(check(i,j)) return 0&puts("YES"); } } } puts("NO"); return 0;}
阅读全文
0 0
- Educational Codeforces Round 25 B. Five-In-a-Row
- Educational Codeforces Round 25 B. Five-In-a-Row
- Educational Codeforces Round 25 B. Five-In-a-Row
- Educational Codeforces Round 25 B Five-In-a-Row 基础题
- Codeforces 825 B Five-In-a-Row
- CodeForces 825B Five-In-a-Row
- Five-In-a-Row CodeForces
- Five-In-a-Row CodeForces
- Five-In-a-Row CodeForces
- Five-In-a-Row CodeForces
- Five-In-a-Row CodeForces
- Five-In-a-Row CodeForces
- B. Five-In-a-Row
- CodeForces 825B:Five-In-a-Row(模拟)
- cf Educational Codeforces Round 6 C Pearls in a Row
- Educational Codeforces Round 6 C. Pearls in a Row
- Educational Codeforces Round 6 C. Pearls in a Row
- Educational Codeforces Round 6 C. Pearls in a Row(贪心)
- windows+linux安装Redis
- Eclipse+maven+scala+spark环境搭建
- openGL 教学素材记录
- 面向对象7---接口
- 2017.7.18 树上距离=k 思考记录
- Educational Codeforces Round 25 B. Five-In-a-Row
- iOS转前端之仿写登录页面
- 关于浏览器隐私/无痕模式下localStorage的判断
- 视觉设计师提升自己能力的17条经验(上)
- CLR Via C# Note--The CLR's execution mode
- 四、Enable and Configure Cross-Database Access
- leetcode 628 Maximum Product of Three Numbers c语言 (找到第k大的数)
- web开发—前言
- 在线教育+直播,千亿市场的新入口