简单题。

/**/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<math.h>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int maxn = 18;
const int inf = 0x7fffffff;
const double pi=acos(-1.0);
const double eps = 1e-8;
char mat[ maxn ][ maxn ];
bool flag;
const int dx[]={1,-1,0,0,-1,-1,1,1};
const int dy[]={0,0,1,-1,-1,1,-1,1};bool in( int x,int y ){if( x>=0&&x<15&&y>=0&&y<15 )return true;elsereturn false;
}bool Judge( int x,int y,char xx ){for( int i=0;i<8;i++ ){int tx = x+dx[i];int ty = y+dy[i];if( in(tx,ty)==true&&mat[tx][ty]==xx )return true;}return false;
}int bfs( int x,int y,char xx ){int tx = x+1;int ty = y;int cnt = 0;while( tx<15 ){if( mat[tx][ty]==xx ){cnt++;tx++;if( cnt>=4 ) break;}else break;}tx = x-1;while( tx>=0 ){if( mat[tx][ty]==xx ){cnt++;tx--;if( cnt>=4 ) break;}else break;}if( cnt>=4 ) return 5;//row to "5"tx = x;ty = y+1;cnt = 0;while( ty<15 ){if( mat[tx][ty]==xx ){cnt++;ty++;if( cnt>=4 ) break;}else break;}ty = y-1;while( ty>=0 ){if( mat[tx][ty]==xx ){cnt++;ty--;if( cnt>=4 ) break;}else break;}if( cnt>=4 ) return 5;// col to "5"tx = x+1;ty = y+1;cnt = 0;while( tx<15&&ty<15 ){if( mat[tx][ty]==xx ){cnt++;tx++;ty++;if( cnt>=4 ) break;}else break;}tx = x-1;ty = y-1;while( tx>=0&&ty>=0 ){if( mat[tx][ty]==xx ){cnt++;tx--;ty--;if( cnt>=4 ) break;}else break;}if( cnt>=4 ) return 5;//right up to "5"tx = x-1;ty = y+1;cnt = 0;while( tx>=0&&ty<15 ){if( mat[tx][ty]==xx ){cnt++;tx--;ty++;if( cnt>=4 ) break;}else break;}tx = x+1;ty = y-1;while( tx<15&&ty>=0 ){if( mat[tx][ty]==xx ){cnt++;tx++;ty--;if( cnt>=4 ) break;}else break;}if( cnt>=4 ) return 5;//left up to "5"return -1;
}int main(){int T;scanf("%d",&T);while( T-- ){int cnt1 = 0;int cnt2 = 0;for( int i=0;i<15;i++ ){scanf("%s",mat[i]);for( int j=0;j<15;j++ ){if( mat[i][j]=='W' ) cnt1++;if( mat[i][j]=='B' ) cnt2++;}}char xx ;if( cnt1==cnt2 ) xx = 'B';else xx = 'W';flag = false;for( int i=0;i<15;i++ ){for( int j=0;j<15;j++ ){if( mat[i][j]=='.'&&Judge( i,j,xx )==true ){//i,j周围有 xxif( bfs( i,j,xx )>=5 ){flag = true;break;}}}if( flag==true ) break;}if( flag ) puts("YES");else puts("NO");}return 0;
}

HDU2699+Easy相关推荐

  1. LeetCode刷题记录15——21. Merge Two Sorted Lists(easy)

    LeetCode刷题记录15--21. Merge Two Sorted Lists(easy) 目录 LeetCode刷题记录15--21. Merge Two Sorted Lists(easy) ...

  2. LeetCode刷题记录14——257. Binary Tree Paths(easy)

    LeetCode刷题记录14--257. Binary Tree Paths(easy) 目录 前言 题目 语言 思路 源码 后记 前言 数据结构感觉理论简单,实践起来很困难. 题目 给定一个二叉树, ...

  3. LeetCode刷题记录13——705. Design HashSet(easy)

    LeetCode刷题记录13--705. Design HashSet(easy) 目录 LeetCode刷题记录13--705. Design HashSet(easy) 前言 题目 语言 思路 源 ...

  4. LeetCode刷题记录12——232. Implement Queue using Stacks(easy)

    LeetCode刷题记录12--232. Implement Queue using Stacks(easy) 目录 LeetCode刷题记录12--232. Implement Queue usin ...

  5. LeetCode刷题记录11——290. Word Pattern(easy)

    LeetCode刷题记录11--290. Word Pattern(easy) 目录 LeetCode刷题记录11--290. Word Pattern(easy) 题目 语言 思路 源码 后记 题目 ...

  6. LeetCode刷题记录10——434. Number of Segments in a String(easy)

    LeetCode刷题记录10--434. Number of Segments in a String(easy) 目录 LeetCode刷题记录9--434. Number of Segments ...

  7. LeetCode刷题记录9——58. Length of Last Word(easy)

    LeetCode刷题记录9--58. Length of Last Word(easy) 目录 LeetCode刷题记录9--58. Length of Last Word(easy) 题目 语言 思 ...

  8. LeetCode刷题记录8——605. Can Place Flowers(easy)

    LeetCode刷题记录8--605. Can Place Flowers(easy) 目录 LeetCode刷题记录8--605. Can Place Flowers(easy) 题目 语言 思路 ...

  9. LeetCode刷题记录7——824. Goat Latin(easy)

    LeetCode刷题记录7--824. Goat Latin(easy) 目录 LeetCode刷题记录7--824. Goat Latin(easy) 题目 语言 思路 后记 题目 题目需要将一个输 ...

最新文章

  1. 【IfICan】脚步很乱!
  2. python discuz搜索api_Django用内置方法实现简单搜索功能的方法
  3. 制作网页版电子时钟特效
  4. wordpress支持MySQL5.5_CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress...
  5. SpringBoot中yaml配置
  6. 在看一个经典教材写的crontab时遇到的点小问题
  7. Web方式预览Office/Word/Excel/pdf文件解决方案
  8. Android studio 常用的插件
  9. HTTPS为什么更安全,先看这些 , 网络加密 , 加密解密
  10. SD卡无法格式化怎么办?解决方法免费分享
  11. 五种常用大数据分析方法
  12. rtf文件怎么打开_什么是RTF文件(以及如何打开一个文件)?
  13. win10系统打开更新服务器失败,Win10系统中Windows Update服务的启动方法
  14. 倒计时3天!这届XIN公益大会很不一般!
  15. ajax 传参的三种方式:
  16. Flickr网站体系结构分析
  17. Git取消add 、 commit、push的命令
  18. Java并发编程 - 第三章 Java内存模型
  19. git 账号密码问题
  20. 【读点论文】A ConvNet for the 2020s,结合swin transformer的结构设计和训练技巧调整resnet网络,在类似的FLOPs和参数量取得更好一点的效果

热门文章

  1. iOS VideoToolbox硬编H.265(HEVC)H.264(AVC):1 概述
  2. IDE神器intellij idea的基本使用
  3. KVM 虚拟机在 IBM System x 上应用_图文详解桥接网络配置
  4. Java7中的switch支持String的实现细节
  5. 网络安全netstat监听网络状态。
  6. linux整理笔记之六:samba软件包使用
  7. 未定义标识符 stringc/c++(20)_20款奔驰G63AMG霸气颜值 运动造型
  8. protoc文件生成cs文件
  9. Redis---持久化
  10. python import caffe失败的可能原因