#include<bits/stdc++.h>
#define re register
using namespace std;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
const int maxn = 110;
int n, m, a[maxn][maxn], dis[maxn][maxn], ans;
inline int dfs(int x, int y){
if(dis[x][y]) return dis[x][y];
dis[x][y] = 1;
for(re int i = 0; i < 4; ++i){
int xx = dx[i] + x;
int yy = dy[i] + y;
if(xx > 0 && yy > 0 && xx <= n && yy <= m && a[x][y] > a[xx][yy]){
dfs(xx, yy);
dis[x][y] = max(dis[x][y], dis[xx][yy] + 1);
}
return dis[x][y];
}
}
int main(){
scanf("%d%d", &n, &m);
for(re int i = 1; i <= n; ++i) for(re int j = 1; j <= m; ++j) scanf("%d", &a[i][j]);
for(re int i = 1; i <= n; ++i) for(re int j = 1; j <= m; ++j) ans = max(ans, dfs(i, j));
printf("%d\n", ans);
}
滑雪大冒险
最新推荐文章于 2023-12-27 12:58:06 发布