简单题。

/*

*/
#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. 【python之旅】python的基础二

    一.集合的操作 1.什么是集合?     集合是一个无序的,不重复的数据组合,它的主要作用如下: 去重:把一个列表变成集合,就自动去重 关系测试:测试两组数据之前的交集,差集,并集等关系   2.常用 ...

  2. sql server 数据库基础学习心得 思维导图

  3. about python

    函数式编程 λ演算 LISP,Erlang 尾递归 栈的使用 避免防御式编程 ER实体Entity关系relationship OOP [OOA/D] 属性.行为 继承.聚合.关联 抽象.封装 笛卡尔 ...

  4. python库tkinter、pygame中几点需要注意的问题

    恍然之间已经16年快四月份了,已经好久都没有写过东西了.. 最近在用python做一些小的游戏,在网上找了一些Python库,Python中游戏编程最常用的还是pygame了,其次是Tkinter p ...

  5. JDK下sun.net.www.protocol.http.HttpURLConnection类-----Http客户端实现类的实现分析

    HttpClient类是进行TCP连接的实现类, package sun.net.www.http; import java.io.*; import java.net.*; import java. ...

  6. 运行从别处复制过来的linux可执行程序

    1, 首先ldd看看缺不缺so文件,如果不缺可忽略下面的文字,直接执行 2, 先看看缺的这些库在系统上有没有,这些库可通过安装开发包,第三方软件进行安装 3, 找到可能会包含这些库的可执行程序,ldd ...

  7. Zoj 3865 Superbot

    按规则移动机器人 , 问是否能拾得宝藏 . 加了一个控制板 , 还增加了一个控制板移动周期 p 将移动周期变换一下 , 移动一次  就相当于光标向左不耗费时间的移动了一格 搜索思路 : 搜索当前格子到 ...

  8. ruby定时脚本

    ruby定时脚本的实现涉及到三个方面: 要定时执行的代码 定时控制(设置定时的时间) 将脚本后台化 实例: # in func.rb def func # the function body goes ...

  9. NEURAL NETWORKS, PART 3: THE NETWORK

    NEURAL NETWORKS, PART 3: THE NETWORK We have learned about individual neurons in the previous sectio ...

  10. Codeforces Round #154 (Div. 2) : B

    一个很简单的题: 方法一: 二分. 代码: #include<cstdio> #include<algorithm> #define maxn 100005 using nam ...