-->
当前位置:首页 > 题库

PROGRAMMING:Maze variant - shortest path

Luz5年前 (2021-05-10)题库458
The figure below shows a maze, with - 1 around the maze representing a wall, and - 1 inside the maze representing an obstacle. Weights 1, 2, 5, and 9 represent the cost of energy consumed. Please find the path from the entrance (3,6) to the exit (8,8) where the mouse consumes the least energy
![ Maze. PNG] (~ / 650cb5b1-29b9-40b9-8927-13a4d1849cf3. PNG)
###Input format:
The first line: the size of the maze, m n, represents the length and height of the maze respectively
The second line: entrance and exit
Other lines: matrix representation of maze
Tip: use 65535 as infinity
###Output format:
The output is the path with the least energy consumption, and the output is in reverse order
###Input example:
Here is a set of inputs. For example:
```in
10 10
3 6 8 8
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 2 1 1 1 1 1 5 1 -1
-1 1 9 9 9 1 1 -1 1 -1
-1 1 1 1 1 1 1 -1 1 -1
-1 1 -1 -1 -1 -1 -1 -1 1 -1
-1 1 9 9 9 1 1 1 1 -1
-1 1 1 1 1 1 1 1 1 -1
-1 1 1 1 1 1 1 1 1 -1
-1 1 1 1 1 1 1 1 2 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
```
###Output example:
The corresponding output is given here. For example:
```out
(8 8)(7 8)(6 8)(5 8)(4 8)(3 8)(2 8)(1 8)(1 7)(1 6)(2 6)(3 6)
```







answer:If there is no answer, please comment