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 ...
随机推荐
- 【转】Android Studio -修改LogCat的颜色*美爆了*
原文网址:http://www.2cto.com/kf/201505/400357.html 一. 先看效果 二.设置 File->Settings 或Ctrl + Alt +S 找到 Edit ...
- JavaScript的事件代理(转)
如果你想给网页添加点JavaScript的交互性,也许你已经听过JavaScript的事件代理(event delegation),并且觉得这是那些发烧友级别的JavaScript程序员才会关心的什么 ...
- hdu 2155 小黑的镇魂曲(dp) 2008信息工程学院集训队——选拔赛
感觉蛮坑的一道题. 题意很像一个叫“是男人下100层”的游戏.不过多了个时间限制,要求在限定时间内从某一点下落到地面.还多了个最大下落高度,一次最多下落这么高,要不然会摔死. 一开始想dp的,然后想了 ...
- ZOJ3865:Superbot(BFS) The 15th Zhejiang University Programming Contest
一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点. 有t组输入 每组输入n, m, p.表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...
- hdu 2870(dp求最大子矩阵)
题意:让你求的是由同一字母组成的最大子矩阵,w可以变成a或者b,x可以变成b或者c,y可以变成a或者c,z可以变成a或者b或者c. 分析:这是hdu 1506.hdu 1505的加强版,具体的分析看我 ...
- 单片机usb转串口的时灵时不灵的解答
写这篇博客,首先检讨一下自己,因为以前串口的程序,也和步进电机一样,时灵时不灵,我现在终于知道这是为什么了,因为51上有三个串口,一个公口,一个母口,一个usb转串口,这样的话,串口有3个了,我手头上 ...
- ACM2025
/* 查找最大元素 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- hdfs 数据块重分布 sbin/start-balancer.sh -threshold
数据块重分布sbin/start-balancer.sh -threshold <percentage of disk capacity>percentage of disk capa ...
- Mahout应用(一)
Mahout应用(一) Mahout 是应用于hadoop上的数据挖掘工具(废话不多说) 这里先简单介绍一下mahout的一般使用方法. 拿kmeans为列子 Mahout中的kmeans所需要的输入 ...
- leetcode@ [316] Remove Duplicate Letters (Stack & Greedy)
https://leetcode.com/problems/remove-duplicate-letters/ Given a string which contains only lowercase ...