简单题。

/*

*/
#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. 添加标签2 jquery 和JS

    TAG添加标签 做了个方法方便调用 一.JS版本 <!DOCTYPE html> <html lang="en"> <head> <met ...

  2. wamp安装注意点!

    安装wamp前或者重装系统后,默认没有依赖的组件VC11,需要先安装才能运行 下载地址:http://www.microsoft.com/en-us/download/details.aspx?id= ...

  3. favicon.ico的使用方法

    favicon.ico怎么来,就自己决定了. 虽说是放在网站根目录下就行了, 但最好是放在网站images目录下,方便统一管理. 然后在head.tpl.php 中的<head></ ...

  4. Mysql主从复制,读写分离

    一个简单完整的 Mysql 主从复制,读写分离的示意图. 1. 首先搭建 Mysql 主从架构,实现 将 mater 数据自动复制到 slave MySQL 复制的工作方式很简单,一台服务器作为主机, ...

  5. Amazon's NoSQL Journey and AWS Operations

    AWS: Amazon Web Services 提供了一整套基础设施和应用程序服务,使您几乎能够在云中运行一切应用程序:从企业应用程序和大数据项目,到社交游戏和移动应用程序. 计算类: EC2:弹性 ...

  6. C语言之 短路原则

    a=0;b=1 c=a&&(b=3) 最终c=0; b=1 因为从左至右进行时,若遇到运算符左边的操作数是 0(逻辑假),则停止运算. a=1;b=1;c=0; d=a||b||(c= ...

  7. Python 处理EXCEL的CSV文档分列求SUM

    相对于导出EXCEL文件,PYTHON计算更为实时. import csv import sys from optparse import OptionParser def calculate_pro ...

  8. servlet单例多线程

    Servlet如何处理多个请求访问? Servlet容器默认是采用单实例多线程的方式处理多个请求的: 1.当web服务器启动的时候(或客户端发送请求到服务器时),Servlet就被加载并实例化(只存在 ...

  9. lc面试准备:Number of 1 Bits

    1 题目 Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also ...

  10. 在前台运行Service

    一个前台的 service是被用户强烈关注的从而不会在内存低时被系统杀死.前台 service必须在状态栏上提供一个通知,这个通知被放在"正在进行"区域中,这表示这个通知不能被解除,除非服务停止了或者 ...