简单题。

/*

*/
#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;
else
return 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周围有 xx
if( bfs( i,j,xx )>=5 ){
flag = true;
break;
}
}
}
if( flag==true ) break;
}
if( flag ) puts("YES");
else puts("NO");
}
return 0;
}

HDU2699+Easy的更多相关文章

  1. 【转】Windows下使用libsvm中的grid.py和easy.py进行参数调优

    libsvm中有进行参数调优的工具grid.py和easy.py可以使用,这些工具可以帮助我们选择更好的参数,减少自己参数选优带来的烦扰. 所需工具:libsvm.gnuplot 本机环境:Windo ...

  2. Struts2 easy UI插件

    一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...

  3. Easy UI常用插件使用

    一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...

  4. UVA-11991 Easy Problem from Rujia Liu?

    Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...

  5. CodeForces462 A. Appleman and Easy Task

    A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input sta ...

  6. easy ui插件

    简介: easy UI是类似于jQuery UI的插件库 注意:多脚本同时使用时,注意脚本冲突问题. 常用插件: 1.tree插件(tree插件实现动态树形菜单) 2.datagrid插件(datag ...

  7. 用TPP开启TDD的easy模式

    Test-Drived Development 测试驱动开发三步曲:写一个失败的测试用例->编写生产代码通过这个测试用例(transformation)->重构(refactor).重构是 ...

  8. Easy Sysprep更新日志-skyfree大神

    Easy Sysprep更新日志: Skyfree 发表于 2016-1-22 13:55:55 https://www.itsk.com/forum.php?mod=viewthread&t ...

  9. [官方软件] Easy Sysprep v4.3.29.602 【系统封装部署利器】(2016.01.22)--skyfree大神

    [官方软件] Easy Sysprep v4.3.29.602 [系统封装部署利器](2016.01.22) Skyfree 发表于 2016-1-22 13:55:55 https://www.it ...

随机推荐

  1. Android 6.0 Permission权限与安全机制

    Marshmallow版本权限修改 android的权限系统一直是首要的安全概念,因为这些权限只在安装的时候被询问一次.一旦安装了,app可以在用户毫不知晓的情况下访问权限内的所有东西,而且一般用户安 ...

  2. Gherkin学习笔记

    前言 由于项目准备使用BDD模式开发,所以最近在学习BDD,同时也记录下自己的学习点滴. 参考原文:https://github.com/cucumber/cucumber/wiki/Gherkin ...

  3. Python 手册——调用解释器

    通常Python的解释器被安装在目标机器的 /usr/local/bin/python 目录下:把 /usr/local/bin 目录放进你的UNIX Shell 的搜索路径里,确保它可以通过输入py ...

  4. UltraEdit软件破解方法

    一.说明 UltraEdit破解软件虽然带有“安装说明.txt”,但是我并没有弄懂--安装说明太模糊.经过一番摸索,找到了破解方法,现记录于此. 二.操作步骤 1.断开网络 2.安装软件 3.打开软件 ...

  5. uitableview的空白处不能响应 touchesbegan 事件

    现在的uitableview 的上面  响应不了     touchesbegan 事件   可能算是苹果的一个bug吧,不知道以后会不会改变 今天试了好久  都不行  最后  写了个字类  继承自 ...

  6. winfrom拷贝文件

    //File.Copy(@"C:\Users\Administrator\Pictures\bg.png", @"g:\images\bg.png", true ...

  7. 【HTTP】IE的URL的最大长度限制和如何解决URL最大长度的限制

    习惯了用户URL传递参数的方便和快捷,然而大多数人并没有了解通过GET方式请求页面并传递一个过长的参数的话,IE浏览器会自动的截取超出最大长度的字符的!微软的权威解释,IE的url最大长度是2083个 ...

  8. node 与php整合

    http://wenku.baidu.com/view/c1810c18b7360b4c2e3f6479.html http://www.xiaocai.name/post/cf1f9_7b6507 ...

  9. Windows Azure 配置SSTP

    方法參考下面文章的步驟. 这个成功.http://freevpnba.com/windows-azure-sstp-vpn/ 这个没成功,不知道为什么.http://diaosbook.com/pos ...

  10. 同样版本的jstl,都是jstl1.2版本,有个有问题,另一个没有问题

    问题是这样的,最近部署一个项目,发现每次访问首页的时候老是报如下的错误: org.springframework.web.util.NestedServletException: Handler pr ...