{$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=3; var N, i, j, t, k, count: integer; sum: real; V: array[1..D] of Coord; L, Kark: array[1..D*(D-1)] of Rebr; P: array[1..D] of integer; procedure PLength (s1, s2: integer; var Res: real); begin Res:=Sqrt (Sqr (Abs (V[s1].X - V[s2].X)) + Sqr (Abs (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:=i+1 to N 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; while i<=N do begin Read (V[i].X, V[i].Y); inc (i); end; k:=-2; for i:=1 to N do begin inc(k); for j:=1 to N do if i<>j then begin t:=k+j; if L[t].f then Continue; PLength (i, j, L[t].Z); L[t].B:=i; L[t].E:=j; L[t].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, ' ', Kark[i].E); Close (Output); end.