博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Fire Maze(广度优先搜索)
阅读量:5153 次
发布时间:2019-06-13

本文共 2333 字,大约阅读时间需要 7 分钟。

Fire Maze
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 53(19 users) Total Accepted: 26(17 users) Rating: Special Judge: No
Description
After escaping from Figo's chase, Severus falls into a N * M maze designed by Figo.

At first, Severus is located on the grid S. Every second he can only move to the four grids that adjacent to the grid he is

 located on. The moment he move to any side of the maze, he will get rid of Figo.

After T seconds, Figo will reach the maze. Because Figo is the designer of the maze, when Figo arrive, he can reach any 

grid if he want. If Severus can't leave the maze at that moment, there is no doubt that he will be caught by Figo.

Figo is very cunning. In the maze he set not only walls, but also fire! After every second, the fire will spread to the four 

grid that adjacent to it. When a grid is on fire, certainly, Severus can not be on the grid. Can Severus escape from the

 maze?

Input
The first line will be a integer CS, indicating the number of test cases. In every case, there will be three integer N, M, T. After that there will be N * M characters, decribe the maze.

The "." is a empty grid, "#" is wall, "F" is the fire, "S" is the initial grid that Severus stands on.

10 <= n , m  <= 100      10 <= T <=10000

Output

There is only one line, if Severus can get out, output the mininum time he need to escape from the maze. If he can't,

 output "Poor Severus must be caught by strong Figo!!!"

Sample Input
2 4 4 4 #### #SF# #..# #..# 3 3 4 ### #S.

#.F

 

Sample Output
3 Poor Severus must be caught by strong Figo!!!
 
#include
#include
#include
#include
#include
#include
#include
using namespace std;int direct[4][2]={ 1,0,0,1,-1,0,0,-1};struct node{ int fireStep; char p; int x,y;} a[101][101],c[10001],z[101],g;int b[101][101];int m,n,t;void FireBfs(node nn){ int i,j; for(i=0;i
=0&&y>=0&&b[x][y]==0) { b[x][y]=1; if(a[x][y].fireStep>a[n1.x][n1.y].fireStep+1||a[x][y].fireStep==-1) { a[x][y].fireStep=a[n1.x][n1.y].fireStep+1; } c[++front]=a[x][y]; } } }}int Bfs(node nn){ int i,j; for(i=0;i
b[n1.x][n1.y]+1&&b[x][y]==-1&&x>=0&&x
=0&&y

 

转载于:https://www.cnblogs.com/beige1315402725/p/5074694.html

你可能感兴趣的文章
2017.3.24上午
查看>>
Python-常用模块及简单的案列
查看>>
(VC/MFC)多线程(Multi-Threading) -1. 基本概念.
查看>>
快数据时代下,Moka携手DataPipeline提升招聘效能
查看>>
day1 用户登陆三次机会
查看>>
LeetCode 159. Longest Substring with At Most Two Distinct Characters
查看>>
LeetCode Ones and Zeroes
查看>>
基本算法概论
查看>>
jquery动态移除/增加onclick属性详解
查看>>
css important
查看>>
KindEditor图片上传到七牛云
查看>>
JavaScript---Promise
查看>>
暖暖的感动
查看>>
Java中的日期和时间
查看>>
Django基于admin的stark组件创建(一)
查看>>
批处理/DOS命令删除文件夹下某类型的文件
查看>>
模板 - 数学 - 矩阵快速幂
查看>>
优秀的持久层框架Mybatis,连接数据库快人一步
查看>>
PAT L2-016 愿天下有情人都是失散多年的兄妹
查看>>
抛弃IIS,利用FastCGI让Asp.net与Nginx在一起
查看>>