Unfortunately you are trapped in an
n × m matrix, each grid either is “
.” denoting ground
which you can stay, or is “#”denoting trap which you can not stay.
On the other hand, you only left
t seconds, so you want to leave this matrix as soon as
possible and you must know every seconds you can move to the adjacent grids(left, right, up and
down), firstly you position is (
1, 1) and your destination is (
n, m).
For each test case, print the case number and your answer, if it is impossible to get to the
destination, output “Impossible”, otherwise output the minimum time you need to get to the
destination.
Case 1: 4
Case 2: Impossible
In the first sample, you can along (2, 1), (2, 2), (2, 3) from (1, 1) to (3, 3)