题目链接:https://vjudge.net/contest/49759#problem/E
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn = 1e2+10;
const int inf = 0x3f3f3f3f;
int n,m;
int num[maxn][maxn];
bool vis[maxn][maxn];
int dp[maxn][maxn];
int dir[4][2]= {
{0,1},{0,-1},{1,0},{-1,0}};
int dfs(int x,int y)
{
if(dp[x][y] > 0)//最长高度已经产生
return dp[x][y];
int xx,yy;
dp[x][y] = 1;//默认最长长度
for(int i = 0; i < 4; ++i)
{
xx = x + dir[i][0];
yy = y + dir[i][1];
if(xx < 0||yy < 0||xx >= n||yy >= m)//相邻点不符合正确的格式,不存在
continue;
if(num[x][y] > num[xx][yy])//相邻点存在而且高度低于这个点
dp[x][y] = max(dp[x][y],dfs(xx,yy)+1);//本点最长长度可以由相邻点的最长