const
mx=30;
var
p:array[1..mx,1..2] of integer;
d:array[1..mx,1..mx] of real;
n,i,j.last:integer;
ans,cur:real;
ansp,curp:array[1..mx] of integer
used:array[1..mx] of boolean;
procedure dfs(k:integer);
var next:integer;
begin
for next:=1 to n do if not used[next] then
begin
if next=last then
begin
dec(last);
while used[last] do dec(last);
if last<i then break;
end;
if cur+d[curp[k-1]][next]<ans then
begin
curp[k]:=next;
cur:=cur+d[curp[k-1]][next];
used[next]:=true;
if k<n-1 then dfs(k+1)
else
begin
if cur+d[curp[k]][last]<ans then
begin
curp[n]:=last;ans:=cur+d[curp[k]][last];
ansp:=curp;
end;
end;
cur:=cur-d[curp[k-1]][next];
used[next]:=false;
if next>last then last:=next;
end;
end;
end;
begin
readln(n);
for i:=1 to n do readln(p[i,1],p[i,2]);
for i:=1 to n-1 do
for j:=i+1 to n do
begin
d[i,j]:=aqrt((p[i,1]-p[j,1])*(p[i,1]-p[j,1]))+(p[i,2]-p[j,2])*(p[i,2]-p[j,2]));
d[j,i]:=d[i,j];
end;
ans:=0;
for i:=1 to n-1 do
begin
ans:=ans+s[i,i+1];
ansp[i]:=i;
end;
ansp[n]:=n;
for i:=1 to n-1 do
begin
cur:=0;
curp[1]:=i;
fillchar(used,sizeof(used),false);
used[i]:=true;
last;=n;
dfs(2);
end;
writeln(ans:0:4);
for i:=1 to n-1 do write(ansp[i],' ');
writeln(ansp[n]);
end.
求大神 要讲解