Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么WA,大牛帮看看!

Posted by LoveZqh at 2008-08-17 22:45:36 on Problem 1088
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator