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. #pragma once

    这是一个比较常用的C/C++杂注,只要在头文件的最开始加入这条杂注,就能够保证头文件只被编译一次. #pragma once是编译器相关的,就是说即使这个编译系统上有效,但在其他编译系统也不一定可以, ...

  2. Win+R指令(2)

    1. gpedit.msc-----组策略 2. sndrec32-------录音机 3. Nslookup-------IP地址侦测器 ,是一个 监测网络中 DNS 服务器是否能正确实现域名解析的 ...

  3. Spring BOOT PERFORMANCE

    转自:http://www.alexecollins.com/spring-boot-performance/ 官方优化文档: https://spring.io/blog/2015/12/10/sp ...

  4. Shell 命令--文件创建、搜索命令--总结自《Linux Shell 脚本攻略》

    (一)文件创建命令 1.touch命令 比如:touch abc命令在本地文件夹中创建了一个名为abc的空文件 2.cp命令 cp命令同意我们把一个文件的内容拷贝到同名或不同名的文件里,复制得到的文件 ...

  5. ThinkPHP3.1 常量参考

    预定义常量 常量 说明 URL_COMMON=0 普通模式 URL URL_PATHINFO=1 PATHINFO URL URL_REWRITE=2 REWRITE URL URL_COMPAT=3 ...

  6. 解决TortoiseCVS中文乱码

    解决TortoiseCVS中文乱码必备,解决方法: 第一:卸载和TortoiseCVS安装一起安装的CVSNT. 第二:安装本版本CVSNT. CVSNT下载地址:http://down.51cto. ...

  7. JavaScript实现竖直文本滚动

    一.HTML代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...

  8. [Webpack 2] Expose modules to dependencies with Webpack

    When you have a dependency that has dependencies on global variables (like jQuery or lodash) or assu ...

  9. [Webpack 2] Optimize React size and performance with Webpack production plugins

    You can fine tune several webpack plugins to make your bundle as small as it can be for your specifi ...

  10. Java基础知识强化之IO流笔记36:InputStreamReader/OutputStreamWriter 复制文本文件案例

    1. 需求:把当前项目目录下的a.txt内容复制到当前项目目录下的b.txt中. 数据源:  a.txt -- 读取数据 -- 字符转换流 -- InputStreamReader 目的地:  b.t ...