lYK, Run! (run)
Time limit:5000ms Memory LIMIT:64MB
"Title description"
lYK trapped in a maze! This maze is the shape of a grid diagram. lYK begins at (a) position, exit at (n,m). And there are a lot of monsters in this maze, if there is a monster in row B of line A, and lYK is in row C, then the monster is |a-c|+|b-d| to its threat level. lYK wanted to find a path that would allow it to reach (n,m) and, as far as possible, threaten the monsters with the least amount of threat on the way. Of course, if there is a monster at the beginning or at the end, no matter what the path, the least threatening beast always = 0.
"Input Format" (run.in)
The first line is two numbers n,m.
The next n rows, the number of M per line, if the number is 0, indicates there is no monster in that position, otherwise there is a monster.
The data guarantees that there is at least one monster.
"Input Format" (run.out)
A number represents the answer.
"Input Sample"
3 4
0 1 1 0
0 0 0 0
1 1 1 0
"Output Example"
1
"Data Range"
For data n=1 of 20%.
For data n<=2 of 40%.
For data n,m<=10 of 60%.
For data n,m<=100 of 80%.
For data n,m<=1000 of 90%.
For another 10% of the data n,m<=1000 and the number of monsters <=100.
"Problem Analysis"
lYK, Run! (run)