P1474 Lehman Rabbit (CSAPC) Accepted Tag: csapc[display label]Describe
This time, Oi Mountain became the new stage of the Endless adventures and legends of the Lehman Bunny! Legend has it that the great treasure is buried in the mountain of Oi, accompanied by a myth: the most magnificent dancers will reach the other side of the Elves world ...
After careful scrutiny, Lehman found this to be a riddle that hints at the location of the treasure, in which a particular path was pointed out, and only the treasure of that path would appear, as follows:
The topography of the Oi Mountain can be seen as a n*n matrix of numbers, consisting of the numbers of 1-n^2 (each number appearing and appearing only once), which represents the elevation of each location. Lehman's starting point is at the highest peak, and every time the Lehman Bunny jumps from its current location to any position lower than the current one, assuming that the x1,y1 jumps from the coordinates (X2,Y2) to the coordinates (the X-y), the jump's magnificence is defined as v= (|x1-x2|+| y1-y2|) ^2. and the path to the secret of the treasure is to jump from the top of the mountain up to the top of the hill (the height of the lowest), and now what we want to know is how much this highest degree of richness is combined.
Format input Format
The first line includes an integer n (n<=50) that represents the length and width of the map.
The next n rows each row includes n number representing the height of each location.
Output format
The output includes an integer ans, representing the highest degree of splendour from the summit to the bottom of the mountain.
Example 1 sample input 1[copy] 2 3 2 1 4 sample output 1[Copy] 9 dp of water;
vijos1474: Lehman Rabbit