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

WHO CAN TELL MW WHAT THE WRONG IS!!!!!(THANKS A LOT)

Posted by RAIN2749435 at 2005-12-10 21:24:02 on Problem 1088
program skiing;
  const fx:array[1..4,1..2] of integer=((0,1),(1,0),(0,-1),(-1,0));
  var a:array[1..10000,1..4] of longint;
      te,i,j,m,n,q,p,max,max2:longint;
      judge:boolean;
procedure qsort(l,r:longint);
  var
    i,j,mid,t:longint;
  begin
    i:=l;j:=r;mid:=a[(l+r)shr 1,1];
    repeat
      while a[i,1]<mid do inc(i);
      while a[j,1]>mid do dec(j);
      if i<=j then
        begin
          t:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=t;
          t:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=t;
          t:=a[i,3];a[i,3]:=a[j,3];a[j,3]:=t;
          inc(i);dec(j);
        end;
    until i>j;
    if l<j then qsort(l,j);
    if i<r then qsort(i,r);
  end;
begin
fillchar(a,sizeof(a),0);
read(m,n);
for i:=1 to m do
  begin
  for j:=1 to n do
    begin
     q:=q+1;
     read(a[q,1]);
     a[q,2]:=i;
     a[q,3]:=j;
     a[q,4]:=1;
    end;
  readln;
  end;

for i:=1 to q do  qsort(1,i);
for i:=q-1 downto 1 do
  begin
  for j:=i+1 to q do
    begin
      judge:=false;
      for te:=1 to 4 do
        begin
          m:=fx[te,1]+a[i,2];
          n:=fx[te,2]+a[i,3];
          if (m=a[j,2])and(n=a[j,3])and(a[j,4]>max) then
            begin
              judge:=true;
              max:=a[j,4];
            end;
        end;
        if judge then
            a[i,4]:=max+a[i,4];
        if a[i,4]>max2 then max2:=a[i,4];
       end;
   end;
   write(max2);
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