2015南阳CCPC G - Ancient Go 暴力
G - Ancient Go
Time Limit: 1 Sec
Memory Limit: 256 MB
题目连接
无
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
Output
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
题意
下围棋,让你下一粒子,然后问你能否至少围住一个o
题解:
数据范围才9*9,直接瞎暴力就行了
枚举每一个位置,都下一个子,然后check就好了
代码:
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<cstring>
using namespace std; string s[];
int vis[][];
int dx[]={,-,,};
int dy[]={,,,-};
int check2(int x,int y)
{
vis[x][y]=;
if(x<||x>=||y<||y>=)return ;
for(int i=;i<;i++)
{
int xx = x+dx[i];
int yy = y+dy[i];
if(xx<||xx>=||yy<||yy>=)continue;
if(vis[xx][yy])continue;
if(s[xx][yy]=='.')return ;
if(s[xx][yy]=='o'&&check2(xx,yy))
return ;
}
return ;
}
int check(int x,int y)
{
if(s[x][y]!='.')return ;
s[x][y]='x';
for(int i=;i<;i++)
{
int xx = x+dx[i];
int yy = y+dy[i];
if(xx<||xx>=||yy<||yy>=)continue;
if(s[xx][yy]=='o')
{
memset(vis,,sizeof(vis));
if(!check2(xx,yy))
return ;
}
}
s[x][y]='.';
return ;
}
int main()
{
int t;scanf("%d",&t);
for(int cas=;cas<=t;cas++)
{
for(int i=;i<;i++)
cin>>s[i];
int flag = ;
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
if(s[i][j]=='o'||s[i][j]=='x')continue;
if(check(i,j))
{
flag = ;
s[i][j]='.';
break;
}
}
}
if(flag)
printf("Case #%d: Can kill in one move!!!\n",cas);
else
printf("Case #%d: Can not kill in one move!!!\n",cas);
}
}
2015南阳CCPC G - Ancient Go 暴力的更多相关文章
- 2015南阳CCPC G - Ancient Go dfs
G - Ancient Go Description Yu Zhou likes to play Go with Su Lu. From the historical research, we fou ...
- 2015南阳CCPC H - Sudoku 暴力
H - Sudoku Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Yi Sima was one of the best cou ...
- 2015南阳CCPC E - Ba Gua Zhen 高斯消元 xor最大
Ba Gua Zhen Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description During the Three-Kingdom perio ...
- 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 ...
- 2015南阳CCPC L - Huatuo's Medicine 水题
L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous ...
- 2015南阳CCPC D - Pick The Sticks dp
D - Pick The Sticks Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description The story happened lon ...
- 2015南阳CCPC A - Secrete Master Plan 水题
D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Master Mind KongMing gave ...
- 2015南阳CCPC L - Huatuo's Medicine 签到
L - Huatuo's Medicine Description Huatuo was a famous doctor. He use identical bottles to carry the ...
- 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 ...
随机推荐
- Oracle 一次 锁表 处理小记
同事说测试库上的一张表被锁了. 不能执行DML 操作. 锁表的准确说法应该是阻塞.之前的一遍blog里有说明: 锁 死锁 阻塞Latch 等待 详解 http://blog.csdn.net/tian ...
- 使用val()另一个妙用------选中select/checkbox/radio的值
一直认为val()方法只有两个功能:1.能设置元素的值,2.获取元素的值.知道val()方法还有另外一个妙用,就是它能使select(下拉列表框).checkbox(多选框)和radio(单选框)相应 ...
- Android学习笔记一
一.eclipse中的十大快捷键: 1. ctrl+shift+r:打开资源 这可能是所有快捷键组合中最省时间的了.这组快捷键可以让你打开你的工作区中任何一个文件,而你只需要按下文件名或mask名中的 ...
- Android 的实现TextView中文字链接的4种方法
Android 的实现TextView中文字链接的方式有很多种. 总结起来大概有4种: 1.当文字中出现URL.E-mail.电话号码等的时候,可以将TextView的android:autoLink ...
- SQL点滴之编辑数据(转)
数据库中的数据编辑是我们遇到的最频繁的工作,这一个随笔中我来总结一下最常用的数据编辑. select into 经常遇到一种情况是,我们希望创建一个新表,表中的数据来源于原有的一个表:原有一个表,但是 ...
- T-SQL 常用语句学习
一.基础 1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- ...
- 【STL】帮你复习STL泛型算法 一
STL泛型算法 #include <iostream> #include <vector> #include <algorithm> #include <it ...
- <转>详解DNS的常用记录(下):DNS系列之三
在上篇博文中我们介绍了DNS服务器中几种不可或缺的记录,包括A记录,NS记录和SOA记录.本篇博文中我们将继续为大家介绍DNS的另外几种常用记录,希望能对大家了解DNS有所帮助. 四 MX记录 MX记 ...
- 最长公共子序列LCS
LCS:给出两个序列S1和S2,求出的这两个序列的最大公共部分S3就是就是S1和S2的最长公共子序列了.公共部分 必须是以相同的顺序出现,但是不必要是连续的. LCS具有最优子结构,且满足重叠子问题的 ...
- 【转】VC6.0附带小工具软件一览
)ActiveX Control Test Container称为"ActiveX 控件测试容器",顾名思义,此工具的主要功能就是测试ActiveX 控件,可以通过改变Active ...