| ||||||||||
| 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 | |||||||||
为什么WA,大牛帮看看!var
map:array [0..501,0..501] of longint;
f:array [0..501,0..501] of longint;
i,j,m,n,k,max:longint;
function dp(x,y:longint):longint;
var
i,j:longint;
begin
i:=x;
j:=y;
if f[x,y]>0 then exit(f[x,y]);
if (map[i-1,j]<>0)and(map[i-1,j]<map[i,j])and(dp(i-1,j)+1>f[i,j]) then f[i,j]:=dp(i-1,j)+1;
if (map[i+1,j]<>0)and(map[i+1,j]<map[i,j])and(dp(i+1,j)+1>f[i,j]) then f[i,j]:=dp(i+1,j)+1;
if (map[i,j-1]<>0)and(map[i,j-1]<map[i,j])and(dp(i,j-1)+1>f[i,j]) then f[i,j]:=dp(i,j-1)+1;
if (map[i,j+1]<>0)and(map[i,j+1]<map[i,j])and(dp(i,j+1)+1>f[i,j]) then f[i,j]:=dp(i,j+1)+1;
exit(f[i,j]);
end;
begin
fillchar(map,sizeof(map),0);
fillchar(f,sizeof(f),0);
readln(m,n);
for i:=1 to m do
for j:=1 to n do
read(map[i,j]);
for i:=1 to m do
for j:=1 to n do begin
k:=dp(i,j);
if k>max then max:=k;
end;
writeln(max+1);
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator