#P9119. [春季测试 2023] 圣诞树
[春季测试 2023] 圣诞树
Problem Description
As everyone knows, Christmas in the year 3202 is coming soon, so little bought a Christmas tree and a wire covered with colorful lights, and plans to wrap this wire around the tree.
The Christmas tree can be regarded as a convex polygon with vertices on a 2D plane. These vertices can be used to fix the wire, and they are numbered in counterclockwise order. The coordinates of vertex are . Let be the index of the vertex with the maximum -coordinate (if there are multiple such vertices, choose the one with the smallest index). It is not guaranteed that the vertex with index has the smallest -coordinate.
The left side of the figure below shows the outline of a Christmas tree, where the vertex with the maximum -coordinate has index .

Little wants to decorate this Christmas tree with the light-covered wire. For aesthetic reasons, she wants the wire to pass through every vertex exactly once. To connect to the power supply, the wire must start from . Formally, she needs to decide a permutation of such that . Then the wire starts from and passes through in order. The wire length is $\sum_{i=1}^{n-1}{\operatorname{d}((x_{p_i}, y_{p_i}), (x_{p_{i+1}}, y_{p_{i+1}}))}$.
- Here is the Euclidean distance on the plane, i.e., $\operatorname{d}((x, y), (x', y')) = \sqrt{(x - x')^2 + (y - y')^2}$.
The right side of the figure above shows one possible plan, where the corresponding permutation is .
To save cost, she wants you to find, among all possible plans, one that makes the wire length as short as possible. If the shortest plan is not unique, you only need to output any one of them.
Considering floating-point errors, your answer is accepted if the relative error or absolute error between your plan and the optimal plan in terms of segment lengths does not exceed .
Input Format
The first line contains a positive integer , representing the number of vertices of the Christmas tree.
The next lines each contain two real numbers accurate to digits after the decimal point, representing the coordinates of vertex .
The data guarantees that these points are pairwise distinct, and connecting in order forms a convex polygon.
Output Format
Output one line containing positive integers separated by single spaces, representing a permutation of such that , and the wire length $\sum_{i=1}^{n-1}{\operatorname{d}((x_{p_i}, y_{p_i}), (x_{p_{i+1}}, y_{p_{i+1}}))}$ is minimal among all possible plans. If such a plan is not unique, output any one of them.
3
0.000000000 0.000000000
3.000000000 0.000000000
1.000000000 1.000000000
3 1 2
Hint
[Sample 1 Explanation]
In this sample, there are only the two plans shown in the figure below, with permutations and . The wire lengths are and , and .
Therefore, the answer permutation is .

[Constraints]
For all data, it is guaranteed that and .
| Test Point ID | Special Property | |
|---|---|---|
| 1, 2 | None | |
| 3, 4, 5, 6 | ||
| 7, 8, 9, 10, 11, 12 | ||
| 13, 14 | A | |
| 15, 16 | B | |
| 17, 18, 19, 20 | None |
Special property A: It is guaranteed that there exists a positive integer such that the input vertices correspond to a consecutive segment of vertices of a regular -gon.
Special property B: It is guaranteed that and .
Translated by ChatGPT 5