problem
solution
codes
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 110;
int r, c, a[maxn][maxn], f[maxn][maxn], ans;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
bool inside(int x, int y){return x>=1&&x<=r&&y>=1&&y<=c;}
int dp(int x, int y){
if(f[x][y])return f[x][y];
int res = 0;
for(int i = 0; i < 4; i++){
int nx = x+dx[i], ny = y+dy[i];
if(inside(nx,ny)&&a[nx][ny]>a[x][y]){
res = max(res,dp(nx,ny));
}
}
return f[x][y]=res+1;
}
int main(){
ios::sync_with_stdio(false);
cin>>r>>c;
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++)
cin>>a[i][j];
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++)
ans = max(ans,dp(i,j));
cout<<ans;
return 0;
}