简单题。

/*

*/
#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. jquery 属性与css操作

    属性1.属性    1.1 attr(name|properties|key,value|key,fn)        1) 获取属性值    $("img").attr(&quo ...

  2. go和swift

    你生命中的有些东西终究会失去,比如我住了6年的陈寨,这个聚集了郑州十几万IT民工的地方,说拆就拆了.再比如我玩了3年的坦克英雄,这个带给我太多快乐的游戏,说停就停了. 编程对我而言是种爱好,我上学6年 ...

  3. IS about 64bit system

    This function supports the 64-bit parts of the registry by using the REGDB_OPTION_WOW64_64KEY option ...

  4. thinkphp使用问题

    下面总结一些,我在使用中遇到的问题,以后遇到了再补充 一.<a>标签的跳转问题 问题:我在控制器Home/Index/index里面使用了Public里面的index.html模板,ind ...

  5. Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法

    转自:http://blog.csdn.net/chuanchuan608/article/details/17915959 目前正在学习python,使用的工具为python3.2.3.发现3x版本 ...

  6. Maya pywin32

    Maya 2011 – 2013 64-bit: maya-64-bit-pywin32.zipMaya 2011 – 2013 32-bit: maya-32-bit-pywin32.zipMaya ...

  7. python 读入

    2 3 4 f=open('message1.txt','r') #这个message1.txt文件应该和这个.py的文件放在同一文件夹下 或者是把路径写全 例: f=open('c:/message ...

  8. 学习Swift--枚举的初步认识 --个人备忘 大神勿喷

    枚举定义了一个通用类型的一组相关值,使你可以在你的代码中以一种安全的方式来使用这些值. // 定义枚举的语法 enum Chips { // 定义了薯片的枚举,包含了3种口味的成员 case Toma ...

  9. BZOJ 4052 Magical GCD

    Description 给出一个长度在\(100000\)以内的正整数序列,大小不超过\(10^{12}\).求一个连续子序列,使得在所有的连续子序列中,它们的GCD值乘以它们的长度最大. Input ...

  10. 控制台console

    先的简单介绍一下chrome的控制台,打开chrome浏览器,按f12就可以轻松的打开控制台 大家可以看到控制台里面有一首诗还有其它信息,如果想清空控制台,可以点击左上角那个来清空,当然也可以通过在控 ...