{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+} {$M 16384,0,655360} program TALLAGE; type Coord=record X, Y: real; end; type Rebr=record B, E: integer; Z: real; f: boolean; end; const D=50; var N, i, j, t, k, count: integer; sum: real; V: array[1..D] of Coord; L, Kark: array[1..D*(D-1) div 2] of Rebr; P: array[1..D] of integer; procedure PLength (s1, s2: integer; var Res: real); begin Res:=Sqrt (Sqr (V[s1].X - V[s2].X) + Sqr (V[s1].Y - V[s2].Y)); end; procedure Zap (i1, i2: integer); var j: integer; begin for j:=1 to N do if P[j]=i2 then P[j]:=i1; end; procedure Kraskala; var i, j: integer; pr: Rebr; begin count:=0; for i:=1 to N-1 do for j:=1 to N-i do if L[i].Z>L[j].Z then begin pr:=L[i]; L[i]:=L[j]; L[j]:=pr; end; for i:=1 to N do begin if P[L[i].B] <> P[L[i].E] then begin inc (count); Kark[count]:=L[i]; if P[L[i].B] > P[L[i].E] then Zap (L[i].E, L[i].B) else Zap (L[i].B, L[i].E); end; end; end; begin Assign (Input, 'TALLAGE.DAT'); Reset (Input); Read (N); i:=1; inc (N); while i<=N do begin Read (V[i].X, V[i].Y); inc (i); end; k:=0; for i:=1 to N do begin for j:=1 to N do if i<>j then begin inc (k); if L[k].f then Continue; PLength (i, j, L[k].Z); L[k].B:=i; L[k].E:=j; L[k].f:=true; end; end; for i:=1 to N do P[i]:=i; Close (Input); Kraskala; Assign (Output, 'TALLAGE.RES'); Rewrite (Output); sum:=0; for i:=1 to count do sum:=sum+Kark[i].Z; Writeln (sum:3:3); for i:=1 to count do Writeln (Kark[i].B-1, ' ', Kark[i].E-1); Close (Output); end.