#1828. 地牢(Dungeon Master)

地牢(Dungeon Master)

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

题目描述

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?


你被困在一个三维地牢,需要尽快逃出。地牢每层每格可以是墙或空气。你可以向东、西、北、南、上、下移动一格,每次移动需要一分钟,不能沿对角线移动,且迷宫四周都是坚固的岩石。

可不可以逃脱? 如果可以,需要多长时间?

输入格式

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,R,CL, R, C都为00

第一行分别有三个数:L,R,CL, R, C(1L,R,C301 \le L, R, C \le 30)。

LL是组成地牢的层数。

R,CR, C是组成每一层的行数和列数。

然后是LLR×CR\times C的字符数组,是每层的平面图。充满岩石的地方由'#'表示,空的单元格由'.'表示。S“S”表示起始位置,E“E”表示逃离位置。每层的平面图后面都有一个空行。

输出格式

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!


每组数据生有一行输出。如果可以逃离,输出如下内容:

Escaped in xx minute(s).

其中xx是为逃离所需的最短时间。

如果无法逃离,则打印如下内容:

Trapped!

样例

样例输入

3 4 5
S....
.###.
.##..
###.#

#####
#####
##.##
##...

#####
#####
#.###
####E

1 3 3
S##
#E#
###

0 0 0

样例输出

Escaped in 11 minute(s).
Trapped!

提示

来自Ulm Local 1997

省秀练习

未参加
状态
已结束
规则
IOI
题目
4
开始于
2024-3-25 16:00
结束于
2024-3-26 2:00
持续时间
10 小时
主持人
参赛人数
27