#P2076. 曼哈顿距离最小生成树
曼哈顿距离最小生成树
Description
Given points in the plane.
Consider the complete graph with nodes. For and , there is an edge between nodes and with weight .
Find a minimum spanning tree of this graph.
Input Format
The first line contains an integer , the number of points.
The next lines, the -th line contains two integers , the coordinates of the -th point.
Output Format
The first line contains an integer , the sum of edge weights in the minimum spanning tree.
Then lines follow. The -th line contains two integers , representing one edge in the minimum spanning tree.
If there are multiple valid answers, you may output any of them.
6
3 8
4 9
2 1
10 5
4 9
2 0
21
5 2
6 3
1 2
3 1
4 1
Hint
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号