博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2251 -- Dungeon Master
阅读量:7115 次
发布时间:2019-06-28

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

Dungeon Master
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 16468   Accepted: 6395

Description

You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonally and the maze is surrounded by solid rock on all sides. 
Is an escape possible? If yes, how long will it take? 

Input

The input consists of a number of dungeons. Each dungeon description starts with a line containing three integers L, R and C (all limited to 30 in size). 
L is the number of levels making up the dungeon. 
R and C are the number of rows and columns making up the plan of each level. 
Then there will follow L blocks of R lines each containing C characters. Each character describes one cell of the dungeon. A cell full of rock is indicated by a '#' and empty cells are represented by a '.'. Your starting position is indicated by 'S' and the exit by the letter 'E'. There's a single blank line after each level. Input is terminated by three zeroes for L, R and C.

Output

Each maze generates one line of output. If it is possible to reach the exit, print a line of the form 
Escaped in x minute(s).
where x is replaced by the shortest time it takes to escape. 
If it is not possible to escape, print the line 
Trapped!

Sample Input

3 4 5S.....###..##..###.#############.####...###########.#######E1 3 3S###E####0 0 0

Sample Output

Escaped in 11 minute(s).Trapped!

1 /*====================================================================== 2  *           Author :   kevin 3  *         Filename :   DungeonMaster.cpp 4  *       Creat time :   2014-08-02 09:40 5  *      Description : 6 ========================================================================*/ 7 #include 
8 #include
9 #include
10 #include
11 using namespace std;12 struct Node13 {14 int x,y,z;15 char c;16 };17 int cnt[31][31][31],vis[31][31][31],xx,yy,zz;18 int cc[6][3]={
{-1,0,0},{
1,0,0},{
0,1,0},{
0,-1,0},{
0,0,1},{
0,0,-1}};19 char s[31][31][31];20 void BFS(int a,int b,int c)21 {22 queue
que;23 Node node,ch,sh;24 int q,w,e;25 node.c=s[a][b][c];26 node.x=a;node.y=b;node.z=c;27 que.push(node);28 while(!que.empty()){29 ch=que.front();30 if(ch.c=='E')31 break;32 que.pop();33 for(int i=0;i<6;i++){34 q=ch.x+cc[i][0];35 w=ch.y+cc[i][1];36 e=ch.z+cc[i][2];37 if(!vis[q][w][e] && q>=0&&q
=0&&w
=0&&e
View Code

 

转载于:https://www.cnblogs.com/ubuntu-kevin/p/3886542.html

你可能感兴趣的文章
微信公众平台开发(108) 微信摇一摇
查看>>
mongodb删除表
查看>>
ASP.NET Core应用针对静态文件请求的处理[3]: StaticFileMiddleware中间件如何处理针对文件请求...
查看>>
ICO与区块链:剖析ICO的金融与技术原理
查看>>
一文读懂深度适配网络(DAN)
查看>>
企业选择数据安全防护平台九个考虑因素
查看>>
当今云计算的挑战:规划,流程和人员
查看>>
用DeepMind教AI玩游戏?一文为你讲清原理!
查看>>
我的WCF之旅(4):WCF中的序列化[上篇]
查看>>
NGINX小技巧--将所有目录和目录下所有文件分别给与不同的权限
查看>>
DOCKER功能练习
查看>>
如何来看单片机外设A/D转换器ADC0804时序图
查看>>
NetApp发布云计算计划及新操作系统
查看>>
IPHONE 6S电池保护壳丑?漂亮的都有专利了
查看>>
云计算和社交网络将推动美科技业重组
查看>>
浙江乌镇已布500多个人脸识别摄像头;宁波、嘉兴将引入中考英语人机对话考试技术,用机器为考生口语评分...
查看>>
15分钟学会使用Git和远程代码库
查看>>
《OpenStack实战》——1.3 关联OpenStack及其控制的计算资源
查看>>
《C++面向对象高效编程(第2版)》——1.15 小结
查看>>
人工智能悖论:简单的动作比复杂的推理更难以实现
查看>>