其他分享
首页 > 其他分享> > Dungeon Master(题目地址链接:https://acs.jxnu.edu.cn/problem/NOIOPJCH02051253)

Dungeon Master(题目地址链接:https://acs.jxnu.edu.cn/problem/NOIOPJCH02051253)

作者:互联网

描述:

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.

输出:

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!

样例输入:

3 4 5

S....

.###.

.##..

###.#

#####

#####

##.##

##...

#####

#####

#.###

####E

1 3 3

S##

#E#

###

0 0 0

样例输出:

Escaped in 11 minute(s).

Trapped!

翻译:

描述:你陷入了一个3D的地牢并且需要去找到最快的方式出去!这个地牢由很多小的立方体方块组成,这些方块可能是被石头填满的。向东向西向南向北向上或者向下移动一个方块需要花费1分钟。你不能够向对角线移动并且这个迷宫四面都被坚硬的岩石围绕。

这有可能逃离吗?如果可能的话,那需要花费多长时间?

输入:

输入由地牢的数量组成。每个地牢的描述由包含三个整数L R 和C(都被限制在30以内)的一行开始。L是地牢的水平数量。

R和C是每个水平的行和列

然后有包含C个方块的R行的L个阻碍。每个方块描述了地牢的小单元。一个小单元充满了岩石用一个‘#’来描述并且空的小单元用一个‘.’来代表。你的开始位置用S来描述并且E表示离开。有一个阻碍的行在每个水平线上。输入用三个字母L R和C来表示。

输出:

每个迷宫有一行输出。如果可以离开地牢,请按以下形式输出一行。

Escaped in x minute(s).

x离开花费的最短的时间放置。

如果不可能离开的话,输出这样一行:

Trapped! 

样例输入:

3 4 5

S....

.###.

.##..

###.#

#####

#####

##.##

##...

#####

#####

#.###

####E

1 3 3

S##

#E#

###

0 0 0

样例输出:

Escaped in 11 minute(s).

Trapped!

标签:Dungeon,地牢,dungeon,acs,方块,#####,line,minute,jxnu
来源: https://blog.csdn.net/R_xin_/article/details/122681901