#include<iostream>
#include<algorithm>
using namespace std;
int rows, cols;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int squ[101][101] = { {0} };
int store[101][101] = { {0} };
int dfs(int x, int y) {
if (store[x][y] != 0) return store[x][y];
for (int i = 0; i < 4; i++) {
int tx = x + dx[i];
int ty = y + dy[i];
if (tx >= 0 && ty >= 0 && tx <= cols && ty <= rows) {
if (squ[x][y] > squ[tx][ty]) {
dfs(tx, ty);
store[x][y] = max(store[x][y], store[tx][ty] + 1);
}
}
}
return store[x][y];
}
int main() {
cin >> rows >> cols;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
cin >> squ[i][j];
}
}
int ans = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
ans = max(dfs(i, j), ans);
}
}
cout << ans + 1;
}
就是这个,找了很久依旧没看出来什么地方出的问题