Convex Polygon MST
Time limit7sMemory limit1024 MB
Given a convex polygon's vertices, find the spanning tree whose edges, weighted by squared Euclidean length, have the maximum total weight.
- Level
Hard8 of 10
- Topics
- Graph, Minimum spanning tree, Geometry
- Solved
- No attempts yet
Problem
There is a convex polygon with vertices on a plane. Let be the set of its vertices. Remove all the edges of the polygon, and then create a tree with vertices by repeating the following operation times:
- Select two distinct vertices . Add an edge between and . If the Euclidean distance between and is , you gain points.
Find the maximum possible total score from the operations.
Input
The input file contains multiple test cases. The first line contains an integer , the number of test cases. Then test cases follow, each in the following format.
⋮
is the number of vertices, with . The sum of all values in one input file is at most . and are the coordinates of the -th vertex, and each coordinate is an integer from to . The vertices are given in counterclockwise order as seen from the centroid of the convex polygon. No three distinct vertices of the convex polygon lie on a single line.
Output
Print the maximum possible total score from the operations.
Hints
The Euclidean distance between and is .
The answer can exceed .