CDOJ 1221 Ancient Go
题目链接:http://acm.uestc.edu.cn/#/problem/show/1221
题目分类:dfs
代码:
#include<bits/stdc++.h> using namespace std; bool ok;
char maze[][];
char Map[][];
bool vis[][];
int x[] = {,,,-};
int y[] = {,-,,}; struct ST
{
int ii;
int jj;
};
queue<ST> que; void BFS(int cur_i, int cur_j)
{
int dot = ;
while(!que.empty())
que.pop();
ST now;
now.ii = cur_i;
now.jj = cur_j;
que.push(now);
while(!que.empty())
{
now = que.front();
que.pop();
vis[now.ii][now.jj] = ;
for(int i=;i<;i++)
{
int tempX = now.ii + x[i];
int tempY = now.jj + y[i];
ST Next;
Next.ii = tempX;
Next.jj = tempY;
if(tempX >= && tempX <= && tempY >= && tempY <= && !vis[tempX][tempY])
{
if(Map[tempX][tempY]=='.')
{
dot++;
vis[tempX][tempY] = ;
}
else if(Map[tempX][tempY]=='o')
{
que.push(Next);
vis[tempX][tempY] = ;
}
}
}
}
if(dot == )
{
ok = ;
}
return ;
} int main()
{
int t;
cin>>t;
int kase = ;
while(t--)
{
ok = ;
for(int i=;i<=;i++)
cin>>maze[i];
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
if(i==||j==||i==||j==)
Map[i][j] = 'x';
else
Map[i][j] = maze[i-][j-];
}
} memset(vis, , sizeof(vis));
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
if(Map[i][j]=='o'&&!vis[i][j])
BFS(i, j);
for(int ii=;ii<=;ii++)
for(int jj=;jj<=;jj++)
if(Map[ii][jj] == '.')
vis[ii][jj] = ;
if(ok)
goto here;
}
}
here:; if(ok)
printf("Case #%d: Can kill in one move!!!\n", kase++);
else
printf("Case #%d: Can not kill in one move!!!\n", kase++);
// cout<<endl;
}
return ;
}
CDOJ 1221 Ancient Go的更多相关文章
- uestc 1221 Ancient Go
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Status Y ...
- BZOJ 1221: [HNOI2001] 软件开发
1221: [HNOI2001] 软件开发 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1428 Solved: 791[Submit][Stat ...
- Ancient Printer[HDU3460]
Ancient Printer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Tot ...
- 【英语学习】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 ...
- 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 ...
- cdoj 1489 老司机采花
地址:http://acm.uestc.edu.cn/#/problem/show/1489 题目: 老司机采花 Time Limit: 3000/1000MS (Java/Others) M ...
- 紫书例题-Ancient Cipher
Ancient Roman empire had a strong government system with various departments, including a secret ser ...
- ural 1249. Ancient Necropolis
1249. Ancient Necropolis Time limit: 5.0 secondMemory limit: 4 MB Aerophotography data provide a bit ...
- The 2015 China Collegiate Programming Contest G. Ancient Go hdu 5546
Ancient Go Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
随机推荐
- SSH框架总结(框架分析+环境搭建+实例源码下载)(转)
首先,SSH不是一个框架,而是多个框架(struts+spring+hibernate)的集成,是目前较流行的一种Web应用程序开源集成框架,用于构建灵活.易于扩展的多层Web应用程序. 集成SSH框 ...
- Android Studio安装教程
Google在2013 I/O大会上发布Android Studio之后,广大Android开发者欢欣鼓舞,不过很快就有人出现问题,Android Studio无法安装,或者安装后无法启动,这篇文章就 ...
- Testin_百度百科
Testin_百度百科 Testin 编辑 目录 1测试平台 2三大特性 #1 真机终端云,节省测试设备购买租赁成本#2 自动化测试,节省测试人员成本及时间# ...
- redisTemplate 操作
redisDao封装类-其他dao集成他 package com.ffcs.wlan.dao.common; import javax.annotation.Resource; import org. ...
- 基于visual Studio2013解决面试题之0502字符串左移
题目
- oracle表连接------>排序合并连接(Merge Sort Join)
排序合并连接 (Sort Merge Join)是一种两个表在做连接时用排序操作(Sort)和合并操作(Merge)来得到连接结果集的连接方法. 对于排序合并连接的优缺点及适用场景例如以下: a,通常 ...
- haproxy redirect location和redirect prefix
<pre name="code" class="html">redirect location <loc> [code <code ...
- uva 1374 快速幂计算
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #i ...
- .net三步配置错误页面,让你的站点远离不和谐的页面
假设你的站点出现一堆让人看不懂的报错,那么你就不是一个合格的程序猿.也不是一个合格的站长. 以下的方面能够帮助你的站点远离让人头大的页面. 第一步:配置web.config 打开web.config, ...
- JavaScript + CSS3 实现的海报画廊特效
原文:JavaScript + CSS3 实现的海报画廊特效 这是慕课网上<CSS3+JS 实现超炫的散列画廊特效>的源代码,我修改了一些 bug 和调优了一些细节,并把学习过程中并不了解 ...