G - Ancient Go

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!!! 题意:下围棋规则,给你一个9*9的棋盘:上面有圈叉,现在轮到你下叉子,判断是否能够杀死至少一枚圈
题解;直接枚举所有下子的情况,判断是否叉围住了至少一个圈。……——……
///
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a))
#define FOR(i,a,b) for( int i=a;i<=b;i++)
#define inf 100000
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//****************************************
#define maxn 11
int ss[][]={-,,,-,,,,};
bool flag,vis[maxn][maxn];
char mp[maxn][maxn];
bool check(int x,int y){
if(x<||y<||x>=||y>=)return ;
return ;
}
void dfs(int x,int y){
if(flag)return ;
for(int i=;i<;i++){
int xx=x+ss[i][];
int yy=y+ss[i][];
if(check(xx,yy)||vis[xx][yy])continue;
if(mp[xx][yy]=='.'){
flag=;return ;
}
if(mp[xx][yy]=='o'){
vis[xx][yy]=;
dfs(xx,yy);
if(flag)return ;
}
}
}
int main(){ int T=read();
int oo=;
while(T--){
for(int i=;i<;i++){
scanf("%s",mp[i]);
}
bool GG=;
for(int i=;i<;i++){
for(int j=;j<;j++){
if(mp[i][j]=='.'){
mp[i][j]='x';
for(int k=;k<;k++){
mem(vis);
int xx=i+ss[k][];
int yy=j+ss[k][];
if(check(xx,yy))continue;
if(mp[xx][yy]=='o')
{
flag=;
vis[xx][yy]=;
dfs(xx,yy);
if(!flag){
GG=;//cout<<i<<" "<<j<<endl;
}
if(GG){break;}
}
}
mp[i][j]='.';
} if(GG){break;}
} if(GG){break;}
}
printf("Case #%d: ",oo++);
if(GG){
cout<<"Can kill in one move!!!"<<endl;
}
else {
cout<<"Can not kill in one move!!!"<<endl;
}
}
return ;
}

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

  1. 2015南阳CCPC G - Ancient Go 暴力

    G - Ancient Go Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Yu Zhou likes to play Go wi ...

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

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

  3. 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 ...

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

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

  5. 2015南阳CCPC H - Sudoku 暴力

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

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

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

  7. 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 ...

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

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

  9. 2015南阳CCPC C - The Battle of Chibi DP

    C - The Battle of Chibi Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Cao Cao made up a ...

随机推荐

  1. Java 基础入门随笔(7) JavaSE版——面向对象定义、特征:封装、构造函数

    面向对象 面向过程:对于面向过程思想,强调的是过程(动作). 面向对象:对于面向对象思想,强调的是对象(实体). 特点: 1,面向对象就是一种常见的思想.符合人们的思考习惯.2,面向对象的出现,将复杂 ...

  2. CAD设置背景图片

    把图片作为背景图片可见但是不能编辑操作. 主要用到函数说明: _DMxDrawX::DrawImageToBackground 绘光栅图到背景.详细说明如下: 参数 说明 BSTR sFileName ...

  3. Spring框架系列(九)--MyBatis面试题(转载)

    1.什么是Mybatis? 1.Mybatis是一个半ORM(对象关系映射)框架,它内部封装了JDBC,开发时只需要关注SQL语句本身,不需要花费精力去处理加载驱动.创建 连接.创建statement ...

  4. reversed()函数和sorted()函数

    #reversed()反转排序,可对列表.元组.区间等进行排序 #练习1 a = range(10) a_list = [x for x in reversed(a)] print(a_list) # ...

  5. 监听微信端,手机端,ios端的浏览器返回事件,pc端关闭事件

    直接上代码了,可以监听微信端,手机端,iOS端的浏览器返回事件,关闭事件不支持 当进入该页面,我们就给这个history压入一个本地的连接.当点击返回.后退及上一页的操作时,就进行监听,在监听代码中实 ...

  6. 40条常见的移动端Web页面问题解决方案

    1.安卓浏览器看背景图片,有些设备会模糊.想让图片在手机里显示更为清晰,必须使用2x的背景图来代替img标签(一般情况都是用2倍).例如一个div的宽高是100100,背景图必须得200200,然后b ...

  7. 关于DEV-c++ 运行窗口闪退的解决办法

    因为程序默认运行结束自动关闭,所以运行窗口会被秒关,反复下载了很多遍也没有解决. 上网看过许多博客后,有好多方法,总结一下: ①在return 0:前加getchar():(getchar():是得到 ...

  8. [luogu4571 JSOI2009] 瓶子和燃料 (数论)

    传送门 Solution 题目说的很迷,但可以发现两个瓶子互相倒最少是容积的gcd 那么题目就转化为求其中选k个瓶子gcd的最大值,这个可以分解因数,枚举因数得到 Code //By Menteur_ ...

  9. [luogu3573 POI2014] RAJ-Rally (拓扑排序 权值线段树)

    传送门 Solution 在DAG中我们可以\(O(n)\)预处理\(Ds(u)\)表示从u表示以s为起点的最长路\(Dt(u)\)表示以u为终点的最长路,那么经过\((u,v)\)的最长路即为\(D ...

  10. 虚拟机下Linux网络配置

    之前配置好了linux系统,在网络这块我用的是桥接模式. 现在分享一下使用虚拟机桥接模式配置Linux网络的过程. 一.首先配置外网的本地Ip地址. 二.配置Linux 网络链接 1.打开linux网 ...