ACE_study @ 2018-12-26 18:16:12
#include<iostream>
using namespace std;
short R,C,a[101][101],xx[5]={0,1,-1,0,0},yy[5]={0,0,0,-1,1};
int f[101][101],ans,ansn=1;
void dfs(short x,short y,int ans1){
if(f[x][y]!=0){
ans1+=f[x][y];
ansn=max(ansn,ans1);
return;
}
for(int i=1;i<=4;i++){
if(x+xx[i]<=R&&x+xx[i]>=1&&y+yy[i]<=C&&y+yy[i]>=1&&a[x+xx[i]][y+yy[i]]<a[x][y]){
ans1++;
dfs(x+xx[i],y+yy[i],ans1);
ans1--;
}
else{
if(i==4){
ansn=max(ansn,ans1);
f[x][y]=ansn;
return;
}
}
}
}
int main(){
cin>>R>>C;
for(short i=1;i<=R;i++){
for(short j=1;j<=C;j++){
cin>>a[i][j];
}
}
for(short i=1;i<=R;i++){
for(short j=1;j<=C;j++){
dfs(i,j,ansn);
ans=max(ans,ansn);
ansn=0;
}
}
cout<<ans<<endl;
return 0;
}
40分,样例过了