suzhibin @ 2018-08-23 19:29:49
#include<bits/stdc++.h>
using namespace std;
int r,c,i,j,dx[5]={0,-1,0,1,0},dy[5]={0,0,1,0,-1},ans=1,a[101][101],f[101][101];
bool check(int a,int b)
{
if(a>=1&&a<=r&&b>=1&b<=c)return true;
else return false;
}
int s(int x,int y)
{
int nx,ny,t=1,tmp;
if(f[x][y])return f[x][y];
for(i=1;i<=4;i++)
{
nx=x+dx[i];
ny=y+dy[i];
if(check(nx,ny)&&(a[x][y]>a[nx][ny]))
{
tmp=s(nx,ny)+1;
t=max(t,tmp);
}
}
f[x][y]=t;
return f[x][y];
}
int main()
{
scanf("%d%d",&r,&c);
for(int i=1;i<=r;i++)
for(int j=1;j<=c;j++)
scanf("%d",&a[i][j]);
for(int i=1;i<=r;i++)
for(int j=1;j<=c;j++)
{
f[i][j]=s(i,j);
ans=max(ans,f[i][j]);
}
printf("%d",ans);
return 0;
}
by Neils_Lin @ 2018-08-30 01:10:06
scanf哪里要改成%lld吧?