代码
#include<bits/stdc++.h>
using namespace std;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int maxn=100+5;
int ans=0;
int pic[maxn][maxn];
int n,m;
void dfs(int x,int y,int step){
if(step>ans)ans=step;
for(int i=0;i<4;i++){
int tx=x+dx[i];
int ty=y+dy[i];
if(tx>=0 and tx<n and ty>=0 and ty<m and pic[x][y]>pic[tx][ty])
dfs(tx,ty,step+1);
}
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
scanf("%d",&pic[i][j]);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
dfs(i,j,1);
}
}
printf("%d",ans);
}