跟你沟通 @ 2020-10-27 22:08:55
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int r,c;
int sum;
int lol;
int h[9999][9999];
bool vis[9999][9999];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
void solve(int x,int y)
{
if(x<1||x>r||y<1||y>c)
{if(lol<sum)lol=sum;return;}
if(vis[x][y]==1)
{if(lol<sum)lol=sum;return;}
sum++;
for(int k=0;k<=3;k++)
if(h[x+dx[k]][y+dy[k]]<h[x][y]&&vis[x+dx[k]][y+dy[k]]==0)
{
vis[x+dx[k]][y+dy[k]]=1;
solve(x+dx[k],y+dy[k]);
vis[x+dx[k]][y+dy[k]]=0;
}
}
int main ()
{
cin>>r>>c;
for(int i=1;i<=r;i++)
for(int j=1;j<=c;j++)
cin>>h[i][j];
for(int i=1;i<=r;i++)
for(int j=1;j<=c;j++)
{vis[i][j]=1;
solve(i,j);
vis[i][j]=0;
}
cout<<lol;
return 0;
//x=x+dx;
//y=y+dy;
}