Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
Submit 
Status

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 and output

Sample Input Sample Output
2

.......xo
.........
.........
..x......
.xox....x
.o.o...xo
..o......
.....xxxo
....xooo. ......ox.
.......o.
...o.....
..o.o....
...o.....
.........
.......o.
...x.....
........o
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.

Source

The 2015 China Collegiate Programming Contest
这题可以用宽搜,枚举所有能放'x'旗子的位置,然后看看有没有'o'被围住。

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define inf 0x7fffffff
#define maxn 12
char s[maxn][maxn];
int vis[maxn][maxn];
int tab[4][2]={0,1,-1,0,0,-1,1,0}; int bfs(int x1,int y1)
{
int i,j,xx,yy,front,rear,flag=1,x,y;
int q[1111][2];
front=rear=1;
q[front][0]=x1;q[front][1]=y1; while(front<=rear){
x=q[front][0];
y=q[front][1];
front++;
for(i=0;i<4;i++){
xx=x+tab[i][0];
yy=y+tab[i][1];
if(xx>=1 && xx<=9 && yy>=1 && yy<=9 && !vis[xx][yy] && s[xx][yy]!='x'){
if(s[xx][yy]=='.'){
flag=0;
}
else{
vis[xx][yy]=1;
rear++;
q[rear][0]=xx;q[rear][1]=yy;
} } }
}
return flag; } int check()
{
int i,j,flag;
memset(vis,0,sizeof(vis));
flag=0;
for(i=1;i<=9;i++){
for(j=1;j<=9;j++){
if(s[i][j]=='o' && !vis[i][j]){
vis[i][j]=1;
flag=bfs(i,j);
if(flag)break;
}
}
if(flag)break;
}
return flag;
} int main()
{
int i,j,T,k,h,flag,cas=0;
scanf("%d",&T);
while(T--)
{
for(i=1;i<=9;i++){
scanf("%s",s[i]+1);
}
flag=0;
for(i=1;i<=9;i++){
for(j=1;j<=9;j++){
if(s[i][j]=='.'){
s[i][j]='x';
flag=check();
if(flag){
break;
}
else{
s[i][j]='.';
}
}
}
if(flag)break;
}
cas++;
if(flag){
printf("Case #%d: Can kill in one move!!!\n",cas);
}
else{
printf("Case #%d: Can not kill in one move!!!\n",cas);
}
}
return 0;
}

uestc 1221 Ancient Go的更多相关文章

  1. CDOJ 1221 Ancient Go

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1221 题目分类:dfs 代码: #include<bits/stdc++.h> using na ...

  2. BZOJ 1221: [HNOI2001] 软件开发

    1221: [HNOI2001] 软件开发 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1428  Solved: 791[Submit][Stat ...

  3. Ancient Printer[HDU3460]

    Ancient Printer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Tot ...

  4. 【英语学习】2016.09.11 Culture Insider: Teacher's Day in ancient China

      Culture Insider: Teacher's Day in ancient China 2016-09-10 CHINADAILY Today is the 32nd Chinese Te ...

  5. ACM:UESTC - 649 括号配对问题 - stack

      UESTC - 649  括号配对问题 Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu ...

  6. Good Bye 2015 D. New Year and Ancient Prophecy

    D. New Year and Ancient Prophecy time limit per test 2.5 seconds memory limit per test 512 megabytes ...

  7. UESTC 1015 Lweb and pepper --前,后缀最值

    题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...

  8. 紫书例题-Ancient Cipher

    Ancient Roman empire had a strong government system with various departments, including a secret ser ...

  9. UESTC 1852 Traveling Cellsperson

    找规律水题... Traveling Cellsperson Time Limit: 1000ms Memory Limit: 65535KB This problem will be judged ...

随机推荐

  1. python中re模块的使用(正则表达式)

    一.什么是正则表达式? 正则表达式,又称规则表达式,通常被用来检索.替换那些符合某个模式(规则)的文本. 正则表达式是对字符串操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合, ...

  2. 【Docker】CentOS7 上无网络情况下安装

    自建虚拟机,但是连接不上网络,只能通过下载rpm包进行安装docker 环境:CentOS 7.3.1611 x64 rpm镜像下载地址用的阿里的https://mirrors.aliyun.com/ ...

  3. 基于Dockfile构建JAVA环境网站镜像

    查看本地目录 [root@docker tomcat]# ls apache-tomcat-8.5.16.tar.gz  Dockerfile  jdk-8u91-linux-x64.tar.gz   ...

  4. postgresql中权限介绍

    postgresql权限分为实例的权限,数据库的权限,模式的权限,对象的权限,表空间的权限 实例的权限:由pg_hba.conf文件控制,控制那些用户那些IP以哪种方式连接数据库 数据库的权限:是否允 ...

  5. DOCKER 安装步骤-最靠谱的笔记

    一.系统环境规划 服务器名 项目名称 docker 操作系统 CentOS Linux release 7.1.1503 (Core) Docker 版本 17.03.2-ce   二.Docker ...

  6. [Ceoi2004]Journey

    题目描述 给出N个点,及你的出发点K. 接下来N-1行描述有关边的开始点,结束点,边长.保证图中不会有环 接下来给出数字J,代表你要走多少个点. 接下来J个数字,代表你要走过的点的编号.当然你可以自己 ...

  7. winform 扫码识别二维码

    因为公司业务需求,需要在Windows系统下调用摄像头识别二维码需求,就有了这个功能. 我根据网上网友提供的一些资料,自己整合应用到项目中,效果还不错(就是感觉像素不是太好) 现在将调用摄像头+识别二 ...

  8. 大数据系列2:Hdfs的读写操作

    在前文大数据系列1:一文初识Hdfs中,我们对Hdfs有了简单的认识. 在本文中,我们将会简单的介绍一下Hdfs文件的读写流程,为后续追踪读写流程的源码做准备. Hdfs 架构 首先来个Hdfs的架构 ...

  9. python_3 装饰器之初次见面

    装饰器 定义:本质是函数,(只不过是用来装饰其他函数而已),就是为其他函数添加附加功能 原则: 1. 不能修改被修饰函数的源代码 2.不能修改被修饰函数的调用方式 实现装饰器的知识储备 1.函数即&q ...

  10. 京东零售mockRpc实践

    https://mp.weixin.qq.com/s/A0T6ySub0DfQiXJAbWm2Qg jsf协议是基于tcp的而且对数据进行了序列化.加密等操作,直接截获的方式很难实现.最后决定注入自己 ...