tchwr 2015-10-28 23:01:24
点我顶贴
收藏
删除
const dx:array[1..4]of integer=(1,0,-1,0);
const dy:array[1..4]of integer=(0,1,0,-1);
var a,f:array[0..101,0..101]of integer;
i,j,n,m,l,tmp,ans,x,y:integer;
function ff(i,j:longint):longint;
var k,nx,ny,t,t1:integer;
begin
t1:=1;
t:=0;
if f[i,j]>0 then begin
ff:=f[i,j];
exit;
end;
for k:=1 to 4 do begin
nx:=i+dx[k];
ny:=j+dy[k];
if (nx>0)and(nx<=n)and(ny>0)and(ny<=m)and(a[nx,ny]>a[i,j]) then begin
t:=ff(nx,ny)+1;
if t1<t then t1:=t;
end;
f[i,j]:=t1;
ff:=t1;
end;
end;
begin
read(n,m);
fillchar(f,sizeof(f),0);
for i:=1 to n do
for j:=1 to m do begin
read(tmp);
a[i,j]:=tmp;
end;
for i:=1 to n do
for j:=1 to m do begin
f[i,j]:=ff(i,j);
if ans<f[i,j] then ans:=f[i,j];
end;
write(ans);
end.