2019/11/2 simulation game && OJ

T1: [Title] Description
cwbc to a maze, the labyrinth is a grid of n row m column, starting at the first row sx
sy column, at the end of the first row tx ty columns. There are a number on each grid maze, the i-th row j-th
row of numbers referred to as a (i, j).
cwbc from the start, every time you can jump to the same row or a same column of the grid, but this
jump will have a certain cost, the size of the cost for all grid points between take-off and landing points (includes both
grid) the minimum number.
cwbc look at these numbers to see dizziness, can only come to you for help, you find from start to finish
minimum total cost.
[Input format
of the first row six positive integer n, the meaning of m, sx, sy, tx, ty, i.e., in the subject description.
Next n lines of m positive integer, describing the labyrinth, the i-th row j-th column is the numbers
a (i, j).
[Format] output
line, a positive integer representing the minimum total cost from the beginning to the end.
[Sample input]
. 5. 4. 3. 4. 3. 1
. 3. 1. 4. 4
. 8. 1 6 6
. 8. 7. 7. 7
. 9. 8. 7 6
[output] Sample
6
[explain] Sample
routes to (3,1) → (1, 1) → (1,4) → ( 1,3) → (4,3).
The total cost is 3 + 1 + 1 + 1 = 6.
[Data] size and restrictions
For all of the test data to ensure that 1 <= n * m <= 100,000, 1 <= a (i, j) <= 1,000.
Ensure the start and end points are different.
Data size and characteristics of the various test points in the following table.

Test Points n,m characteristic
1 <=3
2 <=2000 All a (i, j) is equal to
3 <=70
4



5 <=150
6
7 <=8000
8
9
10

 



We consider the relationship to deal with these points:

Idea: build map + dij

Consider these two-dimensional coordinates to label nodes, were built on the edge all point in the same column of the same row:

The right side is the minimum between these nodes!

Then dij between the start and end points on it

 

Guess you like

Origin www.cnblogs.com/little-cute-hjr/p/11783783.html