TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Given n radio towers in a plane. What is the minimum length for them connecting each other by setting up cable lines? Two towers are connected, if there is a sequence of cable lines connecting together and ending at two towers.

Input Format

There are multiple test cases in the plane. For each test case:


First line contains a number n (1<=n<=100000).
Next n lines there are two integers (x,y) per line indicating the location of each tower. The locations of all towers are pairwise different.


The distance between two towers is calculated by Euclidean distance.


All numbers will not larger than 10000, or less than -10000.

Output Format

For each test case please output the minimum total cable lines' length, two numbers after decimal point.

Sample Input 1

3
0 0
0 3
4 3
7
0 0
0 1
0 2
0 3
0 4
0 5
0 6

Sample Output 1

7.00
6.00

Hints

Problem Source

Migrated from old NTUJ.

Tmt

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 3000 65536 200