#T664. 滑雪
滑雪
Description
It's no surprise that Michael loves skiing, as skiing is indeed an exciting sport. However, to gain speed, the skiing area must slope downward, and once you reach the bottom of the slope, you have to either walk back up or wait for a lift to take you back. Michael wants to know the longest possible ski path in a given area. The area is represented by a two-dimensional array where each number indicates the height of a point. Here's an example:
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
A person can ski from a point to one of the four adjacent points (up, down, left, or right) if and only if the height decreases. In the example above, one possible ski path is 24-17-16-1. However, the path 25-24-23-...-3-2-1 is even longer. In fact, this is the longest possible path.
Input Format
The first line of input indicates the number of rows R and columns C (1 ≤ R, C ≤ 100) of the area. The following R lines each contain C integers representing the height h, where 0 ≤ h ≤ 10000.
Output Format
Output the length of the longest ski path.
```input1 5 5 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 ``` ```output1 25 ``` ## 代码在线