G - Ancient Go

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

Description

Yu Zhou likes to play Go with Su Lu. From the historical research, we found that there are much difference on the rules between ancient go and modern go.

Here is the rules for ancient go they were playing:

The game is played on a 8×8 cell board, the chess can be put on the intersection of the board lines, so there are 9×9 different positions to put the chess.
    Yu Zhou always takes the black and Su Lu the white. They put the chess onto the game board alternately.
    The chess of the same color makes connected components(connected by the board lines), for each of the components, if it's not connected with any of the empty cells, this component dies and will be removed from the game board.
    When one of the player makes his move, check the opponent's components first. After removing the dead opponent's components, check with the player's components and remove the dead components.

One day, Yu Zhou was playing ancient go with Su Lu at home. It's Yu Zhou's move now. But they had to go for an emergency military action. Little Qiao looked at the game board and would like to know whether Yu Zhou has a move to kill at least one of Su Lu's chess.

Input

The first line of the input gives the number of test cases, T(1≤T≤100). T test cases follow. Test cases are separated by an empty line. Each test case consist of 9 lines represent the game board. Each line consists of 9 characters. Each character represents a cell on the game board. . represents an empty cell. x represents a cell with black chess which owned by Yu Zhou. o represents a cell with white chess which owned by Su Lu.

Output

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is Can kill in one move!!! if Yu Zhou has a move to kill at least one of Su Lu's components. Can not kill in one move!!! otherwise.

Sample Input

2

.......xo
.........
.........
..x......
.xox....x
.o.o...xo
..o......
.....xxxo
....xooo. ......ox.
.......o.
...o.....
..o.o....
...o.....
.........
.......o.
...x.....
........o

Sample Output

Case #1: Can kill in one move!!!
Case #2: Can not kill in one move!!!

HINT

题意

下围棋,让你下一粒子,然后问你能否至少围住一个o

题解:

数据范围才9*9,直接瞎暴力就行了

枚举每一个位置,都下一个子,然后check就好了

代码:

#include<stdio.h>
#include<iostream>
#include<math.h>
#include<cstring>
using namespace std; string s[];
int vis[][];
int dx[]={,-,,};
int dy[]={,,,-};
int check2(int x,int y)
{
vis[x][y]=;
if(x<||x>=||y<||y>=)return ;
for(int i=;i<;i++)
{
int xx = x+dx[i];
int yy = y+dy[i];
if(xx<||xx>=||yy<||yy>=)continue;
if(vis[xx][yy])continue;
if(s[xx][yy]=='.')return ;
if(s[xx][yy]=='o'&&check2(xx,yy))
return ;
}
return ;
}
int check(int x,int y)
{
if(s[x][y]!='.')return ;
s[x][y]='x';
for(int i=;i<;i++)
{
int xx = x+dx[i];
int yy = y+dy[i];
if(xx<||xx>=||yy<||yy>=)continue;
if(s[xx][yy]=='o')
{
memset(vis,,sizeof(vis));
if(!check2(xx,yy))
return ;
}
}
s[x][y]='.';
return ;
}
int main()
{
int t;scanf("%d",&t);
for(int cas=;cas<=t;cas++)
{
for(int i=;i<;i++)
cin>>s[i];
int flag = ;
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
if(s[i][j]=='o'||s[i][j]=='x')continue;
if(check(i,j))
{
flag = ;
s[i][j]='.';
break;
}
}
}
if(flag)
printf("Case #%d: Can kill in one move!!!\n",cas);
else
printf("Case #%d: Can not kill in one move!!!\n",cas);
}
}

2015南阳CCPC G - Ancient Go 暴力的更多相关文章

  1. 2015南阳CCPC G - Ancient Go dfs

    G - Ancient Go Description Yu Zhou likes to play Go with Su Lu. From the historical research, we fou ...

  2. 2015南阳CCPC H - Sudoku 暴力

    H - Sudoku Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Yi Sima was one of the best cou ...

  3. 2015南阳CCPC E - Ba Gua Zhen 高斯消元 xor最大

    Ba Gua Zhen Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description During the Three-Kingdom perio ...

  4. 2015南阳CCPC F - The Battle of Guandu 多源多汇最短路

    The Battle of Guandu Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description In the year of 200, t ...

  5. 2015南阳CCPC L - Huatuo's Medicine 水题

    L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous ...

  6. 2015南阳CCPC D - Pick The Sticks dp

    D - Pick The Sticks Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description The story happened lon ...

  7. 2015南阳CCPC A - Secrete Master Plan 水题

    D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Master Mind KongMing gave ...

  8. 2015南阳CCPC L - Huatuo's Medicine 签到

    L - Huatuo's Medicine Description Huatuo was a famous doctor. He use identical bottles to carry the ...

  9. 2015南阳CCPC H - Sudoku 数独

    H - Sudoku Description Yi Sima was one of the best counselors of Cao Cao. He likes to play a funny g ...

随机推荐

  1. 【DFS+堆的二叉树结构】15轻院校赛-J-堆

    [题目链接:J-堆] 1734: 堆 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 239  Solved: 113 SubmitStatusWeb B ...

  2. 如何使用 orachk 工具

    Oracle RAC 安装完毕后的健壮性是一个令人头疼的问题.之前Oracle为之专门推出了raccheck工具,确实方便了我们这些个苦逼的DBA.现在Oracle在raccheck的基础之上又推出了 ...

  3. [Papers]NSE, $u_3$, Lebesgue space [Jia-Zhou, NARWA, 2014]

    $$\bex u_3\in L^\infty(0,T;L^\frac{10}{3}(\bbR^3)). \eex$$

  4. Redis Sentinel机制与用法

    概述 Redis-Sentinel是Redis官方推荐的高可用性(HA)解决方案,当用Redis做Master-slave的高可用方案时,假如master宕机了,Redis本身(包括它的很多客户端)都 ...

  5. sgu 194 Reactor Cooling(有容量上下界的无源无汇可行流)

    [题目链接] http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=20757 [题意] 求有容量上下界的无源无汇可行流. [思路] ...

  6. MFC使用ShowWindow(SW_MAXIMIZE)任务栏消失的处理

    ShowWindow(SW_SHOWMAXIMIZED);//窗口最大化 问题:在写程序时,如果包含了标题栏,但是没有包含最大化按钮或者最小话按钮. 那么人工用ShowWindow(SW_MAXIMI ...

  7. MFC学习知识点20160715

    1.   sizeof()  :返回所查询目标所占用字节数 _countof() :返回所查询目标所含有元素个数 _countof 是 C++中计算一个固定大小数组长度的宏,比如: T arr[10] ...

  8. C++ 我想这样用(四)

    嗯,已经是第四篇了,这篇起我就要开始细说语法了,不过在那之前再次申明下主旨:"C++我想这样用" 系列文案是为C程序员打造的,不是C++程序员. 我的终极目标是:让那些觊觎面向对象 ...

  9. hive优化之------控制hive任务中的map数和reduce数

    一.    控制hive任务中的map数: 1.    通常情况下,作业会通过input的目录产生一个或者多个map任务. 主要的决定因素有: input的文件总个数,input的文件大小,集群设置的 ...

  10. 开元硬件平台 Arduino

    开放源代码的电路图设计,程序开发接口免费下载,也可依个人需求自己修改. Arduino不仅仅是全球最流行的开源硬件,也是一个优秀的硬件开发平台,更是硬件开发的趋势.Arduino简单的开发方式使得开发 ...