#P8999. [CEOI 2022] Drawing

[CEOI 2022] Drawing

Problem Description

You are given NN points on the plane and a tree TT with NN vertices. It is guaranteed that the degree of every vertex in the tree is at most 33, and the vertices of the tree are numbered from 11 to NN.

You need to relabel the given planar points using the labels 1N1 \sim N. After relabeling, for every tree edge e=(u,v)e=(u,v), connect planar point uu and planar point vv 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 NN.

The next N1N-1 lines each contain two integers a,ba, b, meaning there is an edge connecting aa and bb.

The next NN lines each contain two integers x,yx, y, meaning there is a point with coordinates (x,y)(x, y). It is guaranteed that all NN points are pairwise distinct, and no three points are collinear.

Output Format

Output one line with NN integers. The ii-th number should be the assigned label of the original ii-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 0x,y1090 \le x, y \le 10^9.

Subtask ID Special Constraints Score
11 3N2×1053 \le N \le 2\times 10^5, all points are on the convex hull 1010
22 1N40001 \le N \le 4000 1515
33 1N1041 \le N \le 10^4
44 1N8×1041 \le N \le 8\times 10^4 3535
55 1N2×1051 \le N \le 2\times 10^5 2525

Translated by ChatGPT 5