提交时间:2024-04-01 13:31:10
运行 ID: 140910
#include<iostream> using namespace std; int a,b,c,d,e[1005][1005],f; void aa(int x,int y,int z) { if(e[x+1][y]<e[x][y]&&e[x+1][y]!=0) aa(x+1,y,z+1); if(e[x-1][y]<e[x][y]&&e[x-1][y]!=0) aa(x-1,y,z+1); if(e[x][y+1]<e[x][y]&&e[x][y+1]!=0) aa(x,y+1,z+1); if(e[x][y-1]<e[x][y]&&e[x][y-1]!=0) aa(x,y-1,z+1); if((!(e[x+1][y]<e[x][y]&&e[x+1][y]!=0))&&(!(e[x-1][y]<e[x][y]&&e[x-1][y])!=0)&&(!(e[x][y+1]<e[x][y]&&e[x][y+1]!=0))&&(!(e[x][y-1]<e[x][y]&&e[x][y-1]!=0))) { f=max(f,z); return ; } } int main() { cin>>a>>b; for(c=1;c<=a;c++) for(d=1;d<=b;d++) cin>>e[c][d]; for(c=1;c<=a;c++) for(d=1;d<=a;d++) aa(c,d,1); cout<<f; return 0; }