#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int berg[101][101]={0};
int dis[101][101]={0};
int row,column;
int solve(int i,int j)
{
if(!dis[i][j])
{
if(i+1<row&&berg[i+1][j]<berg[i][j])
dis[i][j]=max(dis[i][j],solve(i+1,j)+1);
if(i-1>=0&&berg[i-1][j]<berg[i][j])
dis[i][j]=max(dis[i][j],solve(i-1,j)+1);
if(j+1<column&&berg[i][j+1]<berg[i][j])
dis[i][j]=max(dis[i][j],solve(i,j+1)+1);
if(j-1>=0&&berg[i][j-1]<berg[i][j])
dis[i][j]=max(dis[i][j],solve(i,j-1)+1);
}
return dis[i][j];
}
int main()
{
int max = 0;
scanf("%d%d",&row,&column);
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
scanf("%d",&berg[i][j]);
}
}
for(int i=0;i<row;i++)
{
for(int j=0;j<column;j++)
{
max = max>solve(i,j)?max:dis[i][j];
}
}
cout<<max+1<<endl;
}
|