#P8999. [CEOI 2022] Drawing
[CEOI 2022] Drawing
Problem Description
You are given points on the plane and a tree with vertices. It is guaranteed that the degree of every vertex in the tree is at most , and the vertices of the tree are numbered from to .
You need to relabel the given planar points using the labels . After relabeling, for every tree edge , connect planar point and planar point with a line segment. The requirement is that any two such segments have no intersection points other than possibly at their endpoints.
Construct and output one valid assignment. It is guaranteed that a solution always exists.
Input Format
The first line contains an integer .
The next lines each contain two integers , meaning there is an edge connecting and .
The next lines each contain two integers , meaning there is a point with coordinates . It is guaranteed that all points are pairwise distinct, and no three points are collinear.
Output Format
Output one line with integers. The -th number should be the assigned label of the original -th point.
3
1 2
2 3
10 10
10 20
20 10
1 2 3
5
1 2
1 3
1 4
4 5
10 10
10 30
30 10
30 30
20 25
5 4 2 3 1
6
1 2
2 3
1 4
4 5
4 6
10 60
10 40
40 50
40 30
70 30
70 10
6 5 4 1 2 3
Hint
Explanation of Sample 3

The blue numbers show the assigned labels, and the black numbers show the original labels.
Constraints
For all testdata, it is guaranteed that .
| Subtask ID | Special Constraints | Score |
|---|---|---|
| , all points are on the convex hull | ||
Translated by ChatGPT 5