题目链接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的更多相关文章

  1. uestc 1221 Ancient Go

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

  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. 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 ...

  6. cdoj 1489 老司机采花

    地址:http://acm.uestc.edu.cn/#/problem/show/1489 题目: 老司机采花 Time Limit: 3000/1000MS (Java/Others)     M ...

  7. 紫书例题-Ancient Cipher

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

  8. ural 1249. Ancient Necropolis

    1249. Ancient Necropolis Time limit: 5.0 secondMemory limit: 4 MB Aerophotography data provide a bit ...

  9. 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 ...

随机推荐

  1. UTL_RAW

    The UTL_RAW package provides SQL functions for manipulating RAW data types. 该包的功能其实可以用来加密: SELECT    ...

  2. PHP - 表单与验证

    第11章 表单与验证 学习要点: 1.Header()函数 2.接收及验证数据 我们对Web感兴趣,认为它有用的原因是其主要通过基于HTML的表单发布和收集信息的能力.这些表单用来鼓励网站的反馈.进行 ...

  3. 简单区分`:before`与`::before`的区别

    简单区分:before与::before的区别 :hover我们都知道,称作伪类,英文名pseudo-class,而我们此处提到的:before以及:after也是伪类,属于css2的内容,在ie8下 ...

  4. 网盘大全, 邮箱大全 good

    网盘推荐 115网盘 注册 百度网盘 注册 微云 注册 360云盘 注册 金山快盘 注册 新浪微盘 注册 和彩云 注册 酷盘 注册 OneDrive 外链 BOX 注册 Dropbox 注册 国内网盘 ...

  5. 半透明panel

    用API  SetLayeredWindowAttributes

  6. hdu2489 Minimal Ratio Tree

    hdu2489 Minimal Ratio Tree 题意:一个 至多  n=15 的 完全图 ,求 含有 m 个节点的树 使 边权和 除 点权和 最小 题解:枚举 m 个 点 ,然后 求 最小生成树 ...

  7. QT对话框中show和exec的区别

    转自:http://hi.baidu.com/wangjuns8/blog/item/24b382460dd1c1338694737d.html QDialog的显示有两个函数show()和exec( ...

  8. NGUI: Documentation

    Video Tutorials Basic Tutorial (v.2.5.0+) SD & HD atlas switching (advanced) Packed Font (advanc ...

  9. 电驴 emule 源代码分析 (1)

    关于电驴emule 的源代码,网上有一个  叫刘刚的人 分析的 非常多,可是假设你仅仅是看别人的分析,自己没有亲身去阅读代码的话,恐怕非常难  剖析整个系统. 关于emule  主要就是 连接 kad ...

  10. Effective C++_笔记_条款07_为多态基类声明virtual析构函数

    (整理自Effctive C++,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 这个规则只适用于polymorphic(带多态性质的)base ...