|
|
вернуться в форумWA give me test or hints, or ac program Послано Oleg 29 дек 2002 18:40 var i,j,k,n,m:longint; x,y,r:array[1..200] of real; r1,min:real; a:array [1..200] of longint; procedure sea(l:integer); var j:itneger; begin if k=n then begin if r1<min then min:=r1; end else begin for j:=1 to n do begin if a[j]=1 then continue; r[k]:=sqrt(sqr(x[l]-x[j])+sqr(y[l]-y[j])); r1:=r1+r[k]; inc(k); a[j]:=1; sea(j); a[j]:=0; dec(k); r1:=r1-r[k]; end; end; end; begin read(n); for i:=1 to n do read(x[i],y[i]); min:=3.4E38; k:=1; for i:=1 to n do begin a[i]:=1; sea(i); end; writeln(min:0:3); end. its very litle bug, now its TLE Послано Oleg 29 дек 2002 19:20 var i,j,k,n,m:longint; x,y,r:array[1..200] of real; r1,min:real; a:array [1..200] of longint; procedure sea(l:integer); var j:integer; begin if k=n then begin if r1<min then min:=r1; end else begin for j:=1 to n do begin if a[j]=1 then continue; r[k]:=sqrt(sqr(x[l]-x[j])+sqr(y[l]-y[j])); r1:=r1+r[k]; inc(k); a[j]:=1; sea(j); a[j]:=0; dec(k); r1:=r1-r[k]; end; end; end; begin read(n); for i:=1 to n do read(x[i],y[i]); min:=3.4E38; k:=1; for i:=1 to n do begin a[i]:=1; sea(i); a[i]:=0; end; writeln(min:0:3); end. |
|
|