Ancient Go

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 577    Accepted Submission(s): 213

Problem 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

In the first test case, Yu Zhou has 4 different ways to kill Su Lu's component.

In the second test case, there is no way to kill Su Lu's component.

 
题意:问围棋,下一步能不能吃掉子
分析:暴力。
 
 #include <iostream>
#include <cstdio>
using namespace std; const int n = ;
const int dx[] = {-, , , }, dy[] = {, -, , };
int map[n][n];
int visit[n][n], flagcnt; inline bool Check(int x, int y)
{
if(x < || x >= n || y < || y >= n) return ;
return ;
} inline bool Search(int x, int y)
{
if(map[x][y] == ) return ;
if(map[x][y] == ) return ;
visit[x][y] = flagcnt;
for(int k = ; k < ; k++)
{
int tx = x + dx[k], ty = y + dy[k];
if(Check(tx, ty) && visit[tx][ty] != flagcnt)
{
if(Search(tx, ty))
return ;
}
}
return ;
} inline void Solve()
{
for(int i = ; i < ; i++)
for(int j = ; j < ; j++)
{
char ch = ' ';
while(ch != '.' && ch != 'x' && ch != 'o') ch = getchar();
if(ch == '.') map[i][j] = ;
else if(ch == 'o') map[i][j] = ;
else if(ch == 'x') map[i][j] = ;
} for(int i = ; i< ; i++)
for(int j = ; j < ; j++)
if(map[i][j] == )
{
map[i][j] = ;
for(int k = ; k < ; k++)
{
int x = i + dx[k], y = j + dy[k];
if(Check(x, y) && map[x][y] == )
{
++flagcnt;
if(!Search(x, y))
{
printf("Can kill in one move!!!\n");
return;
}
}
}
map[i][j] = ;
}
printf("Can not kill in one move!!!\n");
} int main()
{
int test;
scanf("%d", &test);
for(int testnumber = ; testnumber <= test; testnumber++)
{
printf("Case #%d: ", testnumber);
Solve();
}
return ;
}

The 2015 China Collegiate Programming Contest G. Ancient Go hdu 5546的更多相关文章

  1. The 2015 China Collegiate Programming Contest K Game Rooms hdu 5550

    Game Rooms Time Limit: 4000/4000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  2. The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540

    Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Othe ...

  3. The 2015 China Collegiate Programming Contest Game Rooms

    Game Rooms Time Limit: 4000/4000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submi ...

  4. The 2015 China Collegiate Programming Contest L. Huatuo's Medicine hdu 5551

    Huatuo's Medicine Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others ...

  5. The 2015 China Collegiate Programming Contest C. The Battle of Chibi hdu 5542

    The Battle of Chibi Time Limit: 6000/4000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Othe ...

  6. Gym 100952G&&2015 HIAST Collegiate Programming Contest G. The jar of divisors【简单博弈】

    G. The jar of divisors time limit per test:2 seconds memory limit per test:64 megabytes input:standa ...

  7. The 2015 China Collegiate Programming Contest H. Sudoku hdu 5547

    Sudoku Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Subm ...

  8. The 2015 China Collegiate Programming Contest E. Ba Gua Zhen hdu 5544

    Ba Gua Zhen Time Limit: 6000/4000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  9. The 2015 China Collegiate Programming Contest D.Pick The Sticks hdu 5543

    Pick The Sticks Time Limit: 15000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others ...

随机推荐

  1. Linear regression with one variable算法实例讲解(绘制图像,cost_Function ,Gradient Desent, 拟合曲线, 轮廓图绘制)_矩阵操作

    %测试数据 'ex1data1.txt', 第一列为 population of City in 10,000s, 第二列为 Profit in $10,000s 1 6.1101,17.592 5. ...

  2. 大数计算_BigNum优化_加减乘除乘方取余_带注释_数组

    #include <iostream> #include <algorithm> #include <cstring> #include <cstdlib&g ...

  3. springmvc中RedirectAttributes的作用

    RedirectAttributes在重定向的时候可以传参,不能跨站传参,因为参数是保存在服务器端

  4. java.util.ConcurrentModificationException

    遍历 List 的时候将 item remove 掉会抛出此异常

  5. NYOJ题目124中位数

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAssAAAJUCAIAAABsWvwaAAAgAElEQVR4nO3dPXLjuraG4TsJ5xqIYw

  6. MVC – 4.mvc初体验(1)

    1.MVC请求模式   2.MVC简单请求流程图 展开 折叠     3.返回string的mvc方法 展开 折叠   4.加载视图的方法  

  7. 设计模式学习之组合模式(Composite,结构型模式)(10)

    转载地址:http://www.cnblogs.com/zhili/p/CompositePattern.html 一.引言 在软件开发过程中,我们经常会遇到处理简单对象和复合对象的情况,例如对操作系 ...

  8. poj 3468:A Simple Problem with Integers(线段树,区间修改求和)

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 58269   ...

  9. Could not link against boost_system 解决办法

    Could not link against boost_system 解决办法: 先安装 libboost-all-dev ./configure --with-incompatible-bdb - ...

  10. RSA 加解密算法

    与DES不同,RSA算法中,每个通信主体都有两个钥匙,一个公钥一个私钥. 就是有2把钥匙1.使用publicKey可以对数据进行加密2.使用Key才能对数据进行解密单方向传输用公钥加密的数据,只有私钥 ...