I'M UNDER ATTACK!
Послано
Neo 9 июн 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.