POJ 2251 Dungeon Master
来源:互联网 发布:博微电力造价软件 编辑:程序博客网 时间:2024/06/10 16:45
Dungeon Master
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 16600 Accepted: 6454
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?
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.
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
where x is replaced by the shortest time it takes to escape.
If it is not possible to escape, print the line
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!
此题也是简单的bfs(广搜),不同的是这道题是三维的,只要开三个数组记录方向即可。
0 0
- poj 2251 Dungeon Master
- poj 2251 Dungeon Master
- poj 2251 Dungeon Master
- poj 2251 Dungeon Master
- Poj 2251 Dungeon Master
- poj 2251 Dungeon Master
- poj 2251 Dungeon Master
- POJ 2251 Dungeon Master
- POJ-2251-Dungeon Master
- POJ 2251Dungeon Master
- poj 2251 Dungeon Master
- poj 2251 Dungeon Master
- poj 2251 Dungeon Master
- POJ 2251 - Dungeon Master
- POJ 2251 Dungeon Master
- POJ 2251 Dungeon Master
- POJ-2251-Dungeon Master
- poj 2251 Dungeon Master
- R 语言开发环境搭建
- 黑马程序员-----------类加载器的基础学习
- Spring MVC初始化研究
- 减肥怎样控制食欲
- 线性表----顺序栈的基本操作
- POJ 2251 Dungeon Master
- 会声会影安装不上
- POJ 2777 Count Color(线段树)
- 【Java就业培训教程】——单态设计模式
- 从零开始,纯手写,创建一个自己的网站
- ~这些年,我们一起学过的java~06~我的五子棋学习之旅~
- 程序员,你需要大量地阅读
- 线性表----链接栈的基本操作
- View的生命周期