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 × cell board, the chess can be put on the intersection of the board lines, so there are × 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(≤T≤). T test cases follow. Test cases are separated by an empty line. Each test case consist of lines represent the game board. Each line consists of 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 ) 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 .......xo
.........
.........
..x......
.xox....x
.o.o...xo
..o......
.....xxxo
....xooo. ......ox.
.......o.
...o.....
..o.o....
...o.....
.........
.......o.
...x.....
........o Sample Output
Case #: Can kill in one move!!!
Case #: Can not kill in one move!!!
Hint In the first test case, Yu Zhou has different ways to kill Su Lu's component. In the second test case, there is no way to kill Su Lu's component.

题意 在.出放一个黑棋X能包围白棋o,只能放一个黑棋

方法 搜索白棋四周有几个空白点如果小于等于1就可以

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
#define N 200
#define met(a,b) memset(a,b,sizeof(a));
vector<vector<int> >Q;
char str[N][N];
int dis[][]= {{,},{,},{-,},{,-}};
int vis[N][N];
int pan(int x,int y)
{
return (x>= && x< && y>= && y<);
}
int dfs(int x,int y)
{
vis[x][y]=;int f=;
for(int i=; i<; i++)
{
int xx = x+dis[i][];
int yy = y+dis[i][];
if(vis[xx][yy] || !pan(xx,yy))///搜过的和坐垫不符合的跳过
continue;
if(str[xx][yy]=='.')///有一个累加
{
f++;
vis[xx][yy]=;
}
if(str[xx][yy]=='o')///四周白棋的四周的空白点个数
f+=dfs(xx,yy);
}
return f;
}
int sove()
{
for(int i=; i<; i++)
{
for(int j=; j<; j++)
{
if(str[i][j]=='o') ///找到一个白棋搜索
{
met(vis,);
int ans=dfs(i,j);
if(ans<=)
return ;
}
}
}
return ;
}
int main()
{
int t,con=;
scanf("%d",&t);
while(t--)
{
for(int i=; i<; i++)
scanf("%s",str[i]); int ans=sove();
if(ans)
printf("Case #%d: Can kill in one move!!!\n",con++);
else
printf("Case #%d: Can not kill in one move!!!\n",con++);
}
return ;
}

(hdu)5546 Ancient Go的更多相关文章

  1. (hdu)5391 Zball in Tina Town

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5391 Problem Description Tina Town is a friendl ...

  2. (hdu)1285 确定比赛名次

    Problem Description 有N个比赛队(<=N<=),编号依次为1,,,....,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接 ...

  3. (hdu)1042 N! 大数相乘

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1042 Problem Description Given an integer N( ≤ ...

  4. (hdu)5234 Happy birthday 二维dp+01背包

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5234 Problem Description Today is Gorwin’s birt ...

  5. (hdu)4858 项目管理 (vector)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4858 Problem Description 我们建造了一个大项目!这个项目有n个节点,用很多边连接起 ...

  6. 杭电(hdu)ACM 4548 美素数

    美素数 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submis ...

  7. (hdu)1257 最少拦截系统

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1257 Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦 ...

  8. (hdu)5423 Rikka with Tree (dfs)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5423 Problem Description As we know, Rikka is p ...

  9. (hdu)2444 The Accomodation of Students 判断二分图+最大匹配数

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2444 Problem Description There are a group of s ...

随机推荐

  1. weka 集成学习

    import java.io.*;import weka.classifiers.*;import weka.classifiers.meta.Vote;import weka.core.Instan ...

  2. Hadoop工程师面试题(1)--MapReduce实现单表汇总统计

    数据源格式描述: 输入t1.txt源数据,数据文件分隔符"*&*",字段说明如下: 字段序号 字段英文名称 字段中文名称 字段类型 字段长度 1 TIME_ID 时间(到时 ...

  3. HW5.24

    import java.util.Calendar; public class Solution { public static void main(String[] args) { System.o ...

  4. C#定义类成员

    1.成员定义 public--成员可以由任何代码访问. private--成员只能由类中的代码访问(如果没有使用任何关键字,就默认使用这个关键字). internal--成员只能由定义它的程序集(项目 ...

  5. Dllimport函数時无法在Dll中找到的入口点

    今天開發客戶提供的一個dll時出現無法找到入口點問題,由於客戶也不能明確說明dll,所以一時不知道如何下手,經查詢後找到可通過vs自帶的dumpbin.exe查看. Dumpbin.exe位于 VS的 ...

  6. [置顶] 漫谈SOA(面向服务架构)

    面向服务架构的思想在整个软件的架构中已经不是什么新鲜的东西.我简单的认为服务化是模块化的延伸,所以服务化有着和模块化类似的优点和缺点.这里不再讨论这些服务定义服务与服务之间的通信协议(像WSDL等等) ...

  7. Script.NET Perl解释器代码已经在GitHub开源发布

    Script.NET Perl解释器的代码已经提交到GitHub网站.GitHub项目地址: https://github.com/blueantst/Script.NET Perl解释器代码在Src ...

  8. jsp <c:forEach> 判断第一条 或 最后一条记录

    <c:forEach>标签具有以下一些属性: var:迭代参数的名称.在迭代体中可以使用的变量的名称,用来表示每一个迭代变量.类型为String. items:要进行迭代的集合.对于它所支 ...

  9. GridControl 复合表头(多行标题)

    说明: 最好是通过编辑视图进行设计,后台编码有点麻烦. 例图:(上面的GC是后台编写 ,下面的是设计器设计) 后台代码编写: public void InitCtrl() { DevExpress.X ...

  10. NSAutoreleasePool' is unavailable: not avail

    NSAutoreleasePool' is unavailable: not available in automatic reference counting mode 这我就纠结了,对着书敲都出问 ...