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 id110202 at 2004-04-27 12:43:57 on Problem 1088
var hill,a,b:array[0..101,0..101]of longint;
    i,j,x,y,s,max:longint;
begin
     read(x,y);
     for i:=1 to x do
         for j:=1 to y do
             read(hill[i,j]);
     fillchar(a,sizeof(a),0);
     fillchar(b,sizeof(b),0);
     for i:=1 to x do
         for j:=1 to y do
              a[i,j]:=1;
     for s:=2 to x*y do
     begin
          for i:=1 to x do
              for j:=1 to y do
              begin
                   b:=a;
                   if hill[i,j]<hill[i+1,j]
                   then begin if b[i,j]<=a[i+1,j] then b[i,j]:=a[i+1,j]+1;end;


                   if hill[i,j]<hill[i,j+1]
                   then begin if b[i,j]<=a[i,j+1] then b[i,j]:=a[i,j+1]+1;end;


                   if hill[i,j]<hill[i-1,j]
                   then begin if b[i,j]<=a[i-1,j] then b[i,j]:=a[i-1,j]+1;end;


                   if hill[i,j]<hill[i,j-1]
                   then begin if b[i,j]<=a[i,j-1] then b[i,j]:=a[i,j-1]+1;end;
                   a:=b;
              end;
     end;
     max:=0;
     for i:=1 to x do
          for j:=1 to y do
              if a[i,j]>max then max:=a[i,j];
     writeln(max);
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