欧阳 @ 2016-08-29 11:28:55
#include<iostream>
#include<cstdio>
using namespace std;
int dx[4]={0,1,0,-1},
dy[4]={1,0,-1,0};
int n,m,a[101][101],f[101][101],ans;
int t,tap,xx,yy;
int search(int x,int y)
{
if(f[x][y]>0) return f[x][y];
t=1;
for(int i=0;i<4;i++)
{
xx=x+dx[i];
yy=y+dy[i];
if((xx>=1)&&(xx<=n)&&(yy>=1)&&(yy<=m)&&(a[x][y]<a[xx][yy]))
{
tap=search(xx,yy)+1;
if(tap>t) t=tap;
}
}
f[x][y]=t;
return (t);
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>a[i][j];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
f[i][j]=search(i,j);
if(f[i][j]>ans)
ans=f[i][j];
}
cout<<ans;
}
by du33169 @ 2017-02-09 19:04:58
ans没有初始化?
忘记return 0;?