ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1119. Metro

1119
Posted by Strike@1908 30 Mar 2004 11:09
Help!
What's wrong with my program.
I get wrong answer in test2.
<
Program 1119;
Var
 amax,n,m,k,a,b,c,d:longint;
 shu:array[1..101]of record
                       x,y:longint;
                     end;
 an:array[1..101]of longint;

Function Qiu(u:longint):longint;
  var
   r:longint;
   max:longint;
  begin
    max:=1;
    for r:=1 to k do
      begin
        if (shu[u].x+1<=shu[r].x)and(shu[u].y+1<=shu[r].y)
          then begin
                 if an[r]=-1
                   then an[r]:=qiu(r);
                 if an[r]+1>max
                   then max:=an[r]+1;
               end;
      end;
    qiu:=max;
  end;

Begin
  readln(n,m);
  readln(k);
  for k:=1 to k do
    begin
      readln(shu[k].x,shu[k].y);
      an[k]:=-1;
    end;
  for a:=1 to k do
    begin
      for b:=1 to k do
        begin
          if ((shu[a].x<shu[b].x)or(shu[a].y<shu[b].y))
             or((shu[a].x=shu[b].x)and(shu[a].y<shu[b].y))
            then begin
                   c:=shu[a].x;d:=shu[a].y;
                   shu[a].x:=shu[b].x;shu[a].y:=shu[b].y;
                   shu[b].x:=c;shu[b].y:=d;
                 end;
        end;
    end;
  for a:=1 to k do
    an[a]:=Qiu(a);
  amax:=0;
  for a:=1 to k do
    begin
      if an[a]>amax
        then amax:=an[a];
    end;
  writeln((n+m-2*amax)*100+amax*100*sqrt(2):0:0);
End.
>