The questions are as follows:
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composedof unit cubes which may or may not be filled with rock. it takes one minuteto move one unit north, south, east, west, up or down. you cannot move diagonally and the maze issurrounded by solid rock on all sides.
Is an escape possible? If yes, how long will it take?
Input specification the input file consists of a number of Dungeons. Each dungeon descriptionstarts with a linecontaining three Integers
L,
RAnd
C(All limited to 30 in size ).
LIs the number of levels making up the dungeon.
RAndCAre the number of rows and columns making up the plan of each level.
Then there will followLBlocksRLines each containingCCharacters. Each character describesone cell of the dungeon. A cell full of rock is indicated by'#'And empty cells are represented by'.'. Your starting position is indicated'SAnd the exit by the letter'E'. There's a single blankline after each level. input is terminated by three zeroesL,RAndC.
Output specification each maze generates one line of output. If it is possible to reach the exit, print a line of the form
Escaped inXMinute (s ).
WhereXIs 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 in a 3D space is no different from a two-dimensional space. Just change it to a three-digit array, 1a.
The AC code is as follows: