1 #include <iostream>
2 using namespace std;
3 #define MaxSize 110
4 int mapmap[MaxSize][MaxSize],dp[MaxSize][MaxSize];
5 int r,c,Max;
6 int go[][2]={{0,1},{0,-1},{1,0},{-1,0}};
7 inline int max(int a,int b){
8 return a>b?a:b;
9 }
10 void dfs(int x,int y){
11 int k,newx,newy;
12 if(dp[x][y]>0)
13 return;
14 newx=x;
15 newy=y;
16 for(k=0;k<4;k++){
17 newx=x+go[k][0];
18 newy=y+go[k][1];
19 if(newx<0||newy<0||newx>=r||newy>=c)
20 continue;
21 if(mapmap[x][y]>mapmap[newx][newy]){
22 if(dp[newx][newy]==0)
23 dfs(newx,newy);
24 dp[x][y]=max(dp[x][y],dp[newx][newy]+1);
25 }
26 }
27 if(Max<dp[x][y])
28 Max=dp[x][y];
29 }
30 int main(){
31 //freopen("in.txt","r",stdin);
32 int i,j;
33 scanf("%d %d",&r,&c);
34 for(i=0;i<r;i++)
35 for(j=0;j<c;j++)
36 scanf("%d",&mapmap[i][j]);
37 memset(dp,0,sizeof(dp));
38 Max=0;
39 for(i=0;i<r;i++)
40 for(j=0;j<c;j++)
41 dfs(i,j);
42 printf("%d\n",Max+1);
43 return 0;
44 }
posted on 2012-07-10 15:35
Leo.W 阅读(100)
评论(0) 编辑 收藏 引用