#P6362. 平面欧几里得最小生成树

    ID: 5331 远端评测题 1500ms 256MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>计算几何Special JudgeO2优化分治生成树凸包

平面欧几里得最小生成树

Description

There are nn points on a plane. The coordinates of point ii are (xi,yi)(x_i, y_i). The edge weight between points ii and jj is (xixj)2+(yiyj)2\sqrt{(x_i - x_j) ^ 2 + (y_i - y_j) ^ 2}. Find the sum of edge weights of the minimum spanning tree.

Input Format

The first line contains an integer nn.

The next nn lines each contain two integers xi,yix_i, y_i.

Output Format

Output one line with a real number, representing the answer.

Your output will be considered correct if the absolute error or relative error compared to the standard output is within 10610^{-6}.

4
0 0
1 2
-1 2
0 4
6.472136

Hint

Sample Explanation 1

In this sample, the minimum spanning tree is shown in the figure below:

The sum of edge weights is 25+26.472135955002 \sqrt{5} + 2 \approx 6.47213595500.


Constraints

  • For 50%50\% of the testdata, n5000n \le 5000.
  • For 100%100\% of the testdata, 3n1053 \le n \le 10 ^ 5, xi\lvert x_i \rvert, yi105\lvert y_i \rvert \le 10 ^ 5.

Translated by ChatGPT 5