HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


50777 - Dwarfs Maze

Guest
• Review clarifications (1)

Volume problems

• 50706 - The most crowded Club
• 50689 - The biggest building block
• 50686 - The Container
• 50771 - BST Level Sum
• 50773 - Balanced Sum Tree
• 50536 - Epoka Furgon Shpk
• 50506 - The Biggest Island
• 50682 - Hotel Durres
• 50777 - Dwarfs Maze
• 50488 - Connecting Wires
• 50472 - Minimum Sum Triangle
• 50842 - Minimum Sum Triangle - DP
• 50781 - ReversesreveR
• 50676 - Cinema Millennium
• 50780 - Hot Potato - Revisited
• 50678 - The Jumping Rabbit
• 50793 - Top M Customers

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