滑雪
#include <iostream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int dirx[] = { 1,-1,0,0 };
const int diry[] = { 0,0,1,-1 };
const int MAXSIZE = 1e2 + 7;
int dp[MAXSIZE][MAXSIZE] = { 0 }, arr[MAXSIZE][MAXSIZE] = { 0 };
int ret = 0, n = 0, m = 0;
//从当前节点 最多走多少步
int dfs(int x,int y) {
if (dp[x][y]) return dp[x][y];
int t = arr[x][y],nCount = 1;
for (int i = 0; i < 4; ++i) {
int nex = x + dirx[i];
int ney = y + diry[i];
if(nex < 0 || ney < 0 || nex >=n || ney >= m ) continue;
if(t <= arr[nex][ney]) { continue;}
//只往比当前小的走 所以无法回头 不需要额外的递归终止条件 走不了就终止了
nCount = max(nCount, dfs(nex, ney) + 1);
}
return nCount;
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j)
cin >> arr[i][j];
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
dp[i][j] = dfs(i, j);
ret = max(ret, dp[i][j]);
}
}
cout << ret << endl;
return 0;
}