#P2130. 狂奔的Wzf
狂奔的Wzf
Description
There is a maze with rows and columns:
| 标识 | 含义 |
|---|---|
$ |
Empty cell, walkable. |
. |
Also an empty cell, also walkable. |
X |
Obstacle, not walkable. |
# |
Goal; Wzf's homework is here. |
Wzf starts from the top-left corner of the maze (row , column ). Each second, it can:
- Choose a direction (up / down / left / right).
- Choose a non-negative integer .
- Take one step in the chosen direction, moving cells:
- It must not cross any obstacle along the way.
- The landing cell must not contain an obstacle.
- It cannot go outside the maze.
Find the minimum number of seconds Wzf needs to reach the goal.
Input Format
The first line contains two integers with .
The next lines each contain characters.
It is guaranteed that there is exactly one #.
It is guaranteed that the cell at row , column is not X.
Output Format
Output a single integer, the minimum number of seconds Wzf needs to reach the goal.
If Wzf cannot reach the goal, output .
2 2
$$
.#
2
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号