wa_answar @ 2024-06-24 22:32:34
#include<bits/stdc++.h>
using namespace std;
int a[1005][1050];
bool b[1005][1005];
int dp[1005][1005];
int main()
{
int r,l;
cin>>r>>l;
for(int i=1;i<=r;i++)
{
for(int j=1;j<=l;j++)
cin>>a[i][j];
}
int num=r*l;
while(num--)
{
int maxn=99999999,idx,idx1;
for(int i=1;i<=r;i++)
{
for(int j=1;j<=l;j++)
{
if(a[i][j]<maxn&&b[i][j]==0)
{
maxn=a[i][j];
idx=i;
idx1=j;
}
}
}
b[idx][idx1]=1;
if(a[idx][idx1+1]>a[idx][idx1]&&idx1+1<=l)
dp[idx][idx1+1]=dp[idx][idx1]+1;
if(a[idx+1][idx1]>a[idx][idx1]&&idx+1<=r)
dp[idx+1][idx1]=dp[idx][idx1]+1;
if(a[idx-1][idx1]>a[idx][idx1]&&idx-1>=1)
dp[idx-1][idx1]=dp[idx][idx1]+1;
if(a[idx][idx1-1]>a[idx][idx1]&&idx1-1>=1)
dp[idx][idx1-1]=dp[idx][idx1]+1;
}
int maxn1=-1;
for(int i=1;i<=r;i++)
{
for(int j=1;j<=l;j++)
maxn1=max(dp[i][j],maxn1);
}
cout<<maxn1+1;
}
90分?????第一个用例点过不了??????????