HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data structures: Stacks, Queues, Linked Lists, etc > problem:


50777 - Dwarfs Maze

Guest
• Review clarifications (1)

Section problems

• 50262 - Brackets
• 50291 - Postfix Arithmetic Expressions
• 50286 - Remove Duplicates
• 50775 - Balanced Parenthesis
• 50340 - Game 19
• 50877 - Friendly Queue
• 51086 - Top popular student
• 50774 - Hot Potato
• 50777 - Dwarfs Maze
• 50781 - ReversesreveR
• 50780 - Hot Potato - Revisited
• 50564 - Mother's Milk Buckets
• 50636 - Brackets
• 50776 - The number of different pa...
• 50779 - The shortest path in a maze

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Kamila Hasanbega.

Dwarfs Maze

In Dwarfs land in order for someone to pass the test to go to the Dwarf-Academy (which is one of the most competitive ones in those regions), someone has to pass a special kind of maze. This maze is 3D and can have 1 ≤ N ≤ 30 floors. Each floor is made of blocks marked by '#' or empty spaces marked by '.' from which you can move, ascend or descend to other floors. Given the plane of each of the maze’s floors the Dwarfs bear the burden of finding the shortest path from the entering portal marked with “B”, to the leaving portal marked with 'F'. Now Tom is not such a witty dwarf, but he heard you are good at algorithms, so he is wondering if you can help him out.

Question: Given the plane of the floors of the maze find the shortest path from the entering to the leaving portal.

Input specification
In the first line will be 1 ≤ a ≤ 5, 1 ≤ b ≤30, 1 ≤ c≤ 30 where 'a' is the number of floors, while b and c are the lengths of width and height of each floor.

Output specification
If there is a way output the number of steps to reach the destination, otherwise output "Impossible".

Sample Input I
2 4 5
B....
.###.
.##..
###.#

#####
#####
##.##
##..F
Sample Input II
1 3 3
B##
###
##F
Sample Output II
10
Sample Output II
Impossible



Äëÿ îòïðàâêè ðåøåíèé íåîáõîäèìî âûïîëíèòü âõîä.

www.contester.ru