level 2
var
p,o,x,y,q,w,v,m,n,xx,i:longint;
l:array[1..1000] of longint;
bo:array[1..1000]of boolean;
a,b:array[1..1000]of double;
f:array[1..1000,1..1000]of double;
k,t,t0,e,e0:real;
procedure change(n1,m1:longint);
var
s:longint;
begin
s:=l[n1];
l[n1]:=l[m1];
l[m1]:=s;
end;
procedure ask(l1,r1:longint);
var
i1:longint;
begin
i1:=l1;
e:=0;
while i1<r1 do
begin
e0:=f[l[i1],l[i1+1]]+e0;
inc(i1);
end;
end;
begin
randomize;
readln(o);
for p:=1 to o do
begin
readln(a[p],b[p]);
end;
for q:=1 to o do
for w:=1 to o do
f[q,w]:=sqrt((a[q]-a[w])*(a[q]-a[w])+(b[q]-b[w])*(b[q]-b[w]));
fillchar(bo,sizeof(bo),true);
for i:=1 to o do
begin
while bo do
xx:=random(o)+1;
l[i]:=xx;
bo[xx]:=false
end;
n:=1;
e:=0;
while n<=o do
begin
e:=f[l[n],l[n+1]]+e;
inc(n);
end;
k:=0.99;
t:=2;
t0:=1;
repeat
begin
n:=random(o)+1;
m:=random(o)+1;
change(n,m);
ask(1,o);
if e0<e then
e:=e0
else if exp(e0-e/t)>(random(10000)/10000) then
begin
e:=e0;
t:=k*t;
end
else change(n,m);
end;
until t<=t0;
writeln(e:0:2);
end.
2016年10月28日 12点10分
5