Mo_tang @ 2022-04-20 20:10:55
#include<bits/stdc++.h>
using namespace std;
int r,c,an;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int a[305][305];
int bus[305][305];
bool jc(int aa,int bb,int as,int bs){
if(aa<=0||aa>r){
return 0;
}
if(bb<=0||bb>c){
return 0;
}
if(a[as][bs]>a[aa][bb]){
return 0;
}
return 1;
}
int wwd(int x,int y){
if(bus[x][y])return bus[x][y];
bus[x][y]=1;
for(int i=0;i<4;i++){
int xa=x+dx[i];
int ya=y+dy[i];
if(jc(xa,ya,x,y)){
wwd(xa,ya);
bus[x][y]=max(bus[x][y],bus[xa][ya]+1);
}
}
return bus[x][y];
}
int main(){
cin>>r>>c;
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
an=max(an,wwd(i,j));
}
}
cout<<an;
return 0;
}
by still_alive @ 2022-04-20 20:52:39
jc函数里面a[as][bs]>a[aa][bb]改成a[as][bs]>=a[aa][bb]试试(等高的滑不过去)