vijos1474: Lehman Rabbit

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.