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. SQL Server 数据类型

    数据类型的选择帮助优化查询,比如针对int类型列和针对文本类型列可能会生成完全不同的查询计划 三种数据类型: 系统数据类型 别名数据类型:用户可以为系统数据类型提供一个别名,并且可以对数据类型做进一步 ...

  2. Tomcat部署的时候 unpackWARs="true"

    在部署项目到Tomcat的时候发现当Tomcat启动的时候,项目并没有解压出来,导致系统传照片的时候找不到路径,因为,系统没有解压,所以找不到路径, 进入地址==>C:\Users\ceshi\ ...

  3. 在HTML中禁止文字的复制

    很简单,只需在<body>中添加如下代码: <body  oncontextmenu='return false' ondragstart='return false' onsele ...

  4. ReentrantLock和synchronized两种锁定机制

    ReentrantLock和synchronized两种锁定机制 >>应用synchronized同步锁 把代码块声明为 synchronized,使得该代码具有 原子性(atomicit ...

  5. 虚拟机Class文件结构笔记

    >>Java语言的平台无关性 Java是与平台无关的语言,“一次编写,到处运行”,这一方面依赖于Java源代码编译后生成的存储字节码的文件,即Class文件是语言和平台无关的: 另一方面依 ...

  6. 图结构练习——最短路径(floyd算法(弗洛伊德))

    图结构练习——最短路径 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述  给定一个带权无向图,求节点1到节点n的最短路径.   输 ...

  7. font-face使用备忘

    @font-face { font-family: 'SingleMalta'; src: url('./font/SingleMalta.ttf'); } @font-face { font-fam ...

  8. Nginx+lua环境搭建

    其实有点类似WampServer一站式安装包 wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz tar -zxvf ng ...

  9. WPF之MVVM(Step4)——使用Prism(2)

    上一篇简单介绍使用Prism中的NotificationObject,以及DelegateCommand.这一篇更是简单,仅仅描述下DelegateCommand<T>如何使用. ICom ...

  10. Vue入门笔记#过渡

    Vue过渡,可以在元素从DOM中移除,插入时自动调用过渡效果.根据设定,会适时的触发过渡效果. 在使用的目标标签里添加 transition: <div transition="my_ ...