[kuangbin带你飞]专题一 简单搜索 B - Dungeon Master(POJ 2251)
2015-11-09 23:40
661 查看
B - Dungeon Master
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status Practice POJ
2251
Appoint description:
System Crawler (2015-11-06)
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
Sample Output
题意:有一个三维地图长度分别为L,R,C, '.'这个为可通过区域,‘#’这个为墙, ‘S'这个为开始位置,’E'这个为出口,求从起点到出口的步数,如果不能到达输出Trapped!,否者输出步数。
求最短距离问题用bfs,bfs记得要判重。
详见代码。
简单搜索题考的是注意。
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status Practice POJ
2251
Appoint description:
System Crawler (2015-11-06)
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 5 S.... .###. .##.. ###.# ##### ##### ##.## ##... ##### ##### #.### ####E 1 3 3 S## #E# ### 0 0 0
Sample Output
Escaped in 11 minute(s). Trapped!
题意:有一个三维地图长度分别为L,R,C, '.'这个为可通过区域,‘#’这个为墙, ‘S'这个为开始位置,’E'这个为出口,求从起点到出口的步数,如果不能到达输出Trapped!,否者输出步数。
求最短距离问题用bfs,bfs记得要判重。
详见代码。
简单搜索题考的是注意。
相关文章推荐
- Qt中事件处理的方法(三种处理方法,四种覆盖event函数,notify函数,event过滤,事件处理器。然后继续传递给父窗口。可观察QWidget::event的源码,它是虚拟保护函数,可改写)
- 并行处理系统测试正式启动
- 并行处理系统测试正式启动
- Map_equals_hashCodeJAVA105-109
- 抽象工厂模式实例
- Scrum Meeting 11.09
- 《HBase权威指南》读书笔记12:第十二章 集群管理
- POJ-1001-浮点数高精度计算
- 朴素贝叶斯——教材上的数据集
- hdu 5202 Rikka with string
- hexo+github搭建博客(mac)
- android界面之间数据的传递
- hdu 5510 Bazinga (kmp+dfs剪枝) 2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
- 关于数据结构三种简单的排序总结
- PM 周刊第 4 期 2015-11-09
- 动手动脑
- 《C陷阱与缺陷》之1词法"陷阱"
- tomcat服务器配置及使用
- hadoop2.7文档翻译第二天
- leetcode-Lowest Common Ancestor of a Binary Search Tree