据说这题叫经典记忆化搜索 瞎写了下就过了

poj1088滑雪_#includepoj1088滑雪_#define_02
 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<stdlib.h>
 5 #include<algorithm>
 6 using namespace std;
 7 #define INF 0xfffffff
 8 int a[110][110],dp[110][110];
 9 int find(int i,int j)
10 {
11     if(dp[i][j])
12     return dp[i][j];
13     int x=0,y=0,z=0,o=0;
14     if(a[i][j]>a[i-1][j])
15     x = find(i-1,j)+1;
16     if(a[i][j]>a[i+1][j])
17     y = find(i+1,j)+1;
18     if(a[i][j]>a[i][j-1])
19     z = find(i,j-1)+1;
20     if(a[i][j]>a[i][j+1])
21     o = find(i,j+1)+1;
22     if(x||y||z||o)
23     return max(max(x,y),max(z,o));
24     return 1;
25 }
26 int main()
27 {
28     int i,j,k,n,m;
29     while(cin>>n>>m)
30     {
31         int g=0;
32         memset(dp,0,sizeof(dp));
33         for(i = 0; i <= n+1 ; i++)
34             for(j = 0; j <= m+1 ; j++)
35             a[i][j] = INF;
36         for(i = 1; i <= n ;i++)
37             for(j = 1;j <= m ; j++)
38                 scanf("%d",&a[i][j]);
39         int maxz=0;
40         for(i = 1; i <= n ; i++)
41             for(j = 1; j <= m ;j++)
42             {
43                 dp[i][j] = find(i,j);
44                 maxz = max(maxz,dp[i][j]);
45             }
46         cout<<maxz<<endl;
47     }
48     return 0;
49 }
View Code