| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
AC标程#include<iostream>
#include<cstdio>
using namespace std;
int dx[5]={0,-1,0,1,0},
dy[5]={0,0,1,0,-1};
long r,c,i,j,p,t,ans;
long m[101][101],f[101][101];
int search(int,int);
int main()
{
cin>>r>>c;
ans=0;
for (i=1;i<=r;i++)
for (j=1;j<=c;j++)
cin>>m[i][j];
for (i=1;i<=r;i++)
for (j=1;j<=c;j++)
{
t=search(i,j);
f[i][j]=t;
if (t>ans) ans=t;
}
cout<<ans<<endl;
}
int search(int x,int y)
{
int i,t,tmp,nx,ny;
if (f[x][y]>0)
{
return (f[x][y]);
}
t=1;
for (i=1;i<=4;i++)
{
nx=x+dx[i];
ny=y+dy[i];
if ((nx>=1)&&(nx<=r)&&(ny>=1)&&(ny<=c)&&(m[x][y]<m[nx][ny]))
{
tmp=search(nx,ny)+1;
if (tmp>t) t=tmp;
}
}
f[x][y]=t;
return (t);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator