https://www.luogu.com.cn/problem/P1434
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MAXN = 105;
int xs[4] = { 0,-1,0,1 }, ys[4] = { -1,0,1,0 };
int a[MAXN][MAXN], p[MAXN][MAXN];
int maxp = 0, r, c;
int dfs(int x, int y) {
if (p[x][y])
return p[x][y];
for (int i = 0; i < 4; i++) {
int xx = x + xs[i];
int yy = y + ys[i];
if (xx >= 0 && xx < r && yy >= 0 && yy < c && a[xx][yy] < a[x][y])
p[x][y] = max(p[x][y], dfs(xx, yy) + 1);
}
if (p[x][y])
return p[x][y];
else
return p[x][y] = 1;//四个方向都高
}
int main() {
IOS;
cin >> r >> c;
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
cin >> a[i][j];
//每个点都需要dfs
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
maxp = max(maxp, dfs(i, j));
cout << maxp << endl;
return 0;
}