题目链接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. GPSR协议移植

    修改的文件有packet.h.cmu-trace.cc.priqueue.cc.ns-packet.tcl.Makefile 1.在 $HOME/ns-allinone-2.29/ns-2.29下新建 ...

  2. C++ 檔案、資料夾、路徑處理函式庫:boost::filesystem

    原帖:https://tokyo.zxproxy.com/browse.php?u=uG7kXsFlW1ZmaxKEvCzu8HrCJ0bXIAddA1s5dtIUZ%2FYzM1u9JI7jjKLT ...

  3. win7系统远程连接其它计算机,并且向远程机传输文件

    首先,打开开始菜单,在程序自带的 “附件“ 中找到 "远程桌面连接"并打开,出现远程桌面对话框: 其次,在对话框左下角点击“选项”,选择“本地资源对话框”,在本地设备和资源下点击“ ...

  4. ORA-01092 ORA-12432: LBAC error: zllegnp:OCIStmtExecute 故障一例

    最近由于数据库hang住,无奈之下直接干掉了pmon进程,再次启动的时候收到了ORA-01092: ORACLE instance terminated. Disconnection forced以及 ...

  5. AngularJS之WebAPi上传

    AngularJS之WebAPi上传(十)   前言 前面一系列我们纯粹是讲AngularJS,在讲一门知识时我们应该结合之前所学综合起来来做一个小的例子,前面我们讲了在MVC中上传文件的例子,在本节 ...

  6. Spring boot jar 后台运行

    start(){ now=`date "+%Y%m%d%H%M%S"` exec java -Xms256m -Xmx512m -jar /alidata/server/webap ...

  7. Linux下使用Mysql

    一.连接MySQL数据库 一个最简单的程序示例: #include <stdio.h> #include "mysql.h" int main() { MYSQL my ...

  8. 第四天学习内容 if switch for 的练习

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  9. Hbase初体验

    搭建local模式搭建, 官网:http://hbase.apache.org API:http://hbase.apache.org/apidocs/index.html download:http ...

  10. 四种方法解决DIV高度自适应问题

    本文和大家重点讨论一下解决DIV高度自适应的方法,这里主要从四个方面来向大家介绍,相信通过本文学习你对DIV高度自适应问题会有更加深刻的认识. DIV高度自适应 关于DIV高度的自适应,一直是个让人头 ...