#P1523. Shortest Bitonic Tour

    ID: 14809 Type: Default 1000ms 256MiB

Shortest Bitonic Tour

Shortest Bitonic Tour

This problem is a simplified version of the famous NP-complete problem.

Given n points on the Cartesian plane (with n ≤ 1000) where each point has integer coordinates ((x,y)) satisfying (-2^{31} < x,y < 2^{31}), the cost of travel between any two points is defined as the Euclidean distance between them.

Your task is to compute the minimum length of a bitonic tour that visits every point exactly once and returns to the starting point.

Note: In a bitonic tour, the points are first visited in increasing order of their x-coordinates and then in decreasing order, ensuring that the tour is split into two monotonic chains. All distance calculations must be expressed in the standard Euclidean metric, i.e., (d((x_1,y_1),(x_2,y_2)) = \sqrt{(x_1-x_2)^2+(y_1-y_2)^2}).

inputFormat

The first line contains an integer n indicating the number of points.

Each of the next n lines contains two space-separated integers representing the coordinates of a point: x and y.

outputFormat

Output the minimum total length of the bitonic tour. The answer should be printed as a floating point number with two digits after the decimal point.

sample

2
0 0
1 1
2.83