| 3289 - Robots inside the Labyrinth Asia - Dhaka - 2005/2006 | |||||
| Submit | Ranking | ||||
Dr. Jemison is simulating the navigation system of a robot. He is using a 2D labyrinth containing several rectangular blocks. All blocks are placed either vertically or horizontally. Spaces are available around the blocks. A robot can use these empty places for its movement. While moving, the robot is not allowed to touch or pass through any block. Also, robots movement must be either horizontal or vertical. A sample scenario is given in the following picture, where rounded blocks indicate the position of robot.
The main aspect of Jemisons experiment is to test whether a robot can turn timely in the right direction and reach its destination. Jemison has already embedded the complete map of the labyrinth and its final position inside the robots memory. As turning is costly, Jemison wants the robot to reach its destination using minimum number of turns. For example, in the above figure, it requires at least two turns to reach the destination.
In this problem you will be given
a labyrinth of infinite extent. There can be zero or more rectangular blocks
inside the labyrinth. Each rectangular block will be defined by its bottom-left
(lx, by)
In the first line, there will be
an integer, T
Two successive input cases will
be separated by a blank line.
For each input set, output must
start with a line `Labyrinth #D
Problemsetter: Md. Kamruzzaman
Input
T
50
N
50
K
20
Output
Sample Input
2
0
2
10 10 20 20
10 10 10 20
1
10 10 100 100
2
9 10 101 10
1 1 1000 1000
Sample Output
Labyrinth #1
1
0
Labyrinth #2
2
1
Dhaka 2005-2006
Special Thanks: Derek Kisman