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. sublime text3 =个人插件

    1.sublime text3汉化插件安装. ctrl+shift+p → Package Control:Install Package → ChineseLocalization preferen ...

  2. CAD把当前图上数据保存为一个二进流对象(com接口VB语言)

    主要用到函数说明: MxDrawXCustomFunction::WriteBinStreamEx 把当前图上数据保存为一个二进流对象,详细说明如下: 参数 说明 LPCTSTR pszPasswor ...

  3. react 导航切换

    <ul class="nav"> <li onClick={() => this.changeFontColor(0)} className={`${0 = ...

  4. Python之list、tuple、dict、set

    参考原文 廖雪峰Python PS:来看看Python中比较特殊的几种数据类型list.tuple.dict.set list list(列表)是Python内置的一种数据类型,它是一种有序.可变的集 ...

  5. [NOIP2017普及]跳房子

    我太弱了... 单调队列优化DP+二分答案. #include <algorithm> #include <iostream> #include <cstdlib> ...

  6. Linux 安装 MySQL 详解(rpm 包)

    说明:Linux 系统中软件的安装在 root 用户下进行,此安装方式为 rpm 包方式,安装的版本为:MySQL-5.6.25-1.linux_glibc2.5.x86_64.rpm-bundle. ...

  7. python实现字符串转换整数

    实现一个函数,使其能将字符串转换成整数. 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止. 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续 ...

  8. buf.readUInt8()

    buf.readUInt8(offset[, noAssert]) offset {Number} 0 <= offset <= buf.length - 1 noAssert {Bool ...

  9. 判断项目中是否有slf4j的实现类

    /** * 判断项目中是否有slf4j的实现类 */ @org.junit.Test public void test() { try { Enumeration<URL> resourc ...

  10. gdb个人使用记录

    参考博客:https://blog.csdn.net/zdy0_2004/article/details/80102076 安装gdb,查看版本确认成功: sudo apt install gdb g ...