ZCfree @ 2024-09-29 10:15:59
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+1;
int mp[N][N];
int n,m;
int h[N][N];
int all;
bool jud(int x,int y)
{
return
(!h[x][y+1]||h[x][y+1]>=h[x][y])&&
(!h[x][y-1]||h[x][y-1]>=h[x][y])&&
(!h[x+1][y]||h[x+1][y]>=h[x][y])&&
(!h[x-1][y]||h[x-1][y]>=h[x][y]);
}
void dfs(int x,int y,int a,int b,int ans)
{
if(mp[x][y])
{
ans+=mp[x][y];
mp[a][b]=max(mp[a][b],ans);
return;
}
ans++;
if(jud(x,y))
{
mp[a][b]=max(mp[a][b],ans);
return;
}
if(h[x][y+1]&&h[x][y+1]<h[x][y])dfs(x,y+1,a,b,ans);
if(h[x][y-1]&&h[x][y-1]<h[x][y])dfs(x,y-1,a,b,ans);
if(h[x+1][y]&&h[x+1][y]<h[x][y])dfs(x+1,y,a,b,ans);
if(h[x-1][y]&&h[x-1][y]<h[x][y])dfs(x-1,y,a,b,ans);
return;
}
int main()
{
memset(mp,0,sizeof(mp));
cin>>m>>n;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>h[i][j];
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
dfs(i,j,i,j,0);
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
//cout<<mp[i][j]<<" ";
all=max(all,mp[i][j]);
}
//cout<<endl;
}
cout<<all;
}
by ZCfree @ 2024-09-29 13:38:49
@ZCfree 好了现在90了 ……
by ZCfree @ 2024-09-29 15:06:12
@ZCfree 6
by ZCfree @ 2024-09-29 17:27:26
@ZCfree 6
by ZCfree @ 2024-09-29 19:41:55
@ZCfree ZENMBAN