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 1056. Centers of the Net

I'M UNDER ATTACK!
Posted by Neo 9 Jun 2003 09:21
ACM attacks me!Why I got WA??

Here's my WA program:

var
  n:integer;
  s,mins:real;
  a:array[1..7,1..7] of real;
  b:array[1..7] of integer;
  sb:array[1..7] of integer;
function func(u,d,l,r:integer):real;
begin
  func:=sqrt(abs(sqr((u-d))+sqr((l-r))));
end;
procedure r;
var x1,x2,i,j,k:integer;x:array[1..2,1..7] of integer;
begin
  k:=0;
  readln(n);
  for i:=1 to ((n-1) div 2) do
    begin
      read(x1,x2);
      for j:=1 to k do
        begin
          a[j,k]:=func(x[j,1],x[j,2],x1,x2);
          a[k,j]:=a[j,k];
        end;
      x[k,1]:=x1;x[k,2]:=x2;
      k:=k+1;
    end;
end;
procedure print;
var j,k:integer;
begin
  for j:=1 to 2 do
    if sb[j]<>0 then write(sb[j],' ');
end;
procedure try(i:integer);
var
  j,k,m:integer;
  d:array[1..7] of boolean;
begin
  fillchar(d,sizeof(d),0);
  k:=0;
  for j:=1 to n do
    if (not d[j]) and (s<mins)
       then begin
              k:=k+1;
              b[k]:=j;
              d[j]:=true;
              s:=s+a[i,j];
              if (j=n) and (s<mins)
                 then begin for m:=1 to n do sb[m]:=b[m];mins:=s;end;
            end;
end;
begin
  s:=0;
  mins:=maxint;
  r;
  try(1);
  print;
end.
Re: I'M UNDER ATTACK!
Posted by Rustam 3 Sep 2008 16:09
did you use sort for it?