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

谁帮我看一下到底错在那了?想不明白,谢谢

Posted by ChemicalRain at 2004-12-16 12:44:44 on Problem 1088
用记忆化搜索实现的
Program PKU1088;
var
   map,ans:array[0..101,0..101] of integer;
   calc:array[0..101,0..101] of boolean;
   i,j,m,n,w,h,max,t:integer;
function f(x,y:integer):integer;
var
   tmp:integer;
begin
f:=0;
   if x*y=0  then exit;
   if x>w then exit;
   if y>h then exit;
   if calc[x,y] then
      begin
        f:=ans[x,y];
        exit;
      end;
  if map[x-1,y]<map[x,y] then
     begin
       tmp:=f(x-1,y);
       if tmp+1>ans[x,y] then ans[x,y]:=tmp+1;
     end;
  if map[x+1,y]<map[x,y] then
     begin
       tmp:=f(x+1,y)+1;
       if tmp>ans[x,y] then ans[x,y]:=tmp;
     end;
  if map[x,y-1]<map[x,y] then
     begin
       tmp:=f(x,y-1)+1;
       if tmp>ans[x,y] then ans[x,y]:=tmp;
     end;
     if map[x,y+1]<map[x,y] then
     begin
       tmp:=f(x,y+1)+1;
       if tmp>ans[x,y] then ans[x,y]:=tmp;
     end;
calc[x,y]:=true;
f:=ans[x,y];
end;
begin
while not eoln do
  begin
   fillchar (map,sizeof(map),0);
   fillchar (ans,sizeof(ans),0);
    readln (w,h);
    for i:=1 to w do
     begin
      for j:=1 to h do
        read (map[i,j]);
        readln;
     end;
  max:=0;fillchar (calc,sizeof(calc),false);
  for i:=1 to w do
    for j:=1 to h do
       begin
         t:=f(i,j);
         if t>max then max:=t;
       end;
writeln (max);
end;
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