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 ...
随机推荐
- UVALive 6584 Escape (Regionals 2013 >> Europe - Central)
题目 给出一棵树,每个节点有一个怪物或血药,遇到怪物必须打,打完后扣掉一定的血量. 一开始英雄的血量为\(0\),当血量小于\(0\)时就挂了. 给出英雄的起点和终点,问能否成功到达终点. 算法 这题 ...
- IE6 png图片实现半透明的方法
IE6中支持PNG半透明图片完美解决方法-divcss5亲測 从IE7及IE7以上版本号都支持PNG半透明格式图片,而只有IE6不支持png格式透明图片,而GIF半透明效果不及png半透明格式图片,由 ...
- PCI-X总线
PCI-X接口是并连的PCI总线(Peripheral Components Interconnect)的更新版本号,仍採用传统的总线技术,只是有很多其它数量的接线针脚, 同一时候,如前所述的全部的连 ...
- BZOJ 1529: [POI2005]ska Piggy banks( 并查集 )
每一连通块砸开一个就可以拿到所有的钱, 所以用并查集求连通块数 ------------------------------------------------------------------- ...
- API通用设计原则
什么是好的API? · 完备(Be Complete) 对确定重点支持的用户场景具有完备的功能支持.就是说,用户通过对一组API的调用能够完成预期的功能. · 不冗余(Be ...
- 强大的Http监控工具Fidder
软件下载:http://fiddler2.com/get-fiddler 软件学习:http://www.cnblogs.com/TankXiao/archive/2012/02/06/2337728 ...
- android 定时拍照并发送微博
最近在做android方面的开发,下面是android自动对焦并拍照的小例子: package com.comnvi.camera; import java.io.File; import java. ...
- hdu1391(Number Steps )
Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...
- Linux 下获取LAN中指定IP的网卡的MAC(物理地址)
// all.h// 2005/06/20,a.m. wenxy #ifndef _ALL_H#define _ALL_H #include <memory.h>#include < ...
- python datetime模块strptime/strptime format常见格式命令_施罗德_新浪博客
python datetime模块strptime/strptime format常见格式命令_施罗德_新浪博客 python datetime模块strptime/strptime form ...