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

PROGRAMMING:Little h likes to sleep

Luz5年前 (2021-05-10)题库441
Xiao h likes to sleep very much. On this day, he got up and saw that it was 9.30, and he promised to go to Xiao w's house at 10 o'clock. Xiao h wants to go. He knows the shortest time for Xiao h to go to Xiao w's house. Can you help him.
The map is n * m grid, each unit is an open space or building (unable to pass through), small h is added at (1,1), small w is at (x, y), he can only move up, down, left and right, each step takes 1 minute. Input data to ensure that the small w home can be reached.
###Input format:
The first row has two positive integers n, m, separated by spaces (1 < = n, m < = 100), where n is the row and M is the column
Next are two positive integers x, y, separated by spaces (1 < = x < = n, 1 < = y < = m) to indicate the coordinates of the teaching building
Next is the map with n rows and m columns, 0 for open space and 1 for obstacles.
###Output format:
For each test case, a line containing an integer is output, which gives the shortest time (in minutes) for small h to reach small W.
###Input example:
```in
5 4
4 3
0 0 1 0
0 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1
```
###Output example:
```out
seven
```







answer:If there is no answer, please comment