Score : 600 points
问题陈述
在二维平面上有 2N 个点 P1,P2,…,PN,Q1,Q2,…,QN。点 Pi 的坐标是 (Ai,Bi),点 Qi 的坐标是 (Ci,Di)。没有三个不同的点在同一条直线上。
确定是否存在一个排列 R=(R1,R2,…,RN) 的 (1,2,…,N) 满足以下条件。如果存在这样的 R,请找出一个。
- 对于从 1 到 N 的每个整数 i,让线段 i 是连接 Pi 和 QRi 的线段。那么,线段 i 和线段 j (1≤i<j≤N) 永远不会相交。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are 2N points P1,P2,…,PN,Q1,Q2,…,QN on a two-dimensional plane. The coordinates of Pi are (Ai,Bi), and the coordinates of Qi are (Ci,Di). No three different points lie on the same straight line.
Determine whether there exists a permutation R=(R1,R2,…,RN) of (1,2,…,N) that satisfies the following condition. If such an R exists, find one.
- For each integer i from 1 through N, let segment i be the line segment connecting Pi and QRi. Then, segment i and segment j (1≤i<j≤N) never intersect.
Constraints
- 1≤N≤300
- 0≤Ai,Bi,Ci,Di≤5000 (1≤i≤N)
- (Ai,Bi)=(Aj,Bj) (1≤i<j≤N)
- (Ci,Di)=(Cj,Dj) (1≤i<j≤N)
- (Ai,Bi)=(Cj,Dj) (1≤i,j≤N)
- No three different points lie on the same straight line.
- All input values are integers.
The input is given from Standard Input in the following format:
N
A1 B1
A2 B2
⋮
AN BN
C1 D1
C2 D2
⋮
CN DN
Output
If there is no R satisfying the condition, print -1.
If such an R exists, print R1,R2,…,RN separated by spaces. If there are multiple solutions, you may print any of them.
3
0 0
2 4
4 2
0 2
2 0
4 4
Sample Output 1
2 1 3
The points are arranged as shown in the following figure.

By setting R=(2,1,3), the three line segments do not cross each other. Also, any of R=(1,2,3), (1,3,2), (2,3,1), and (3,1,2) is a valid answer.
8
59 85
60 57
72 12
3 27
16 58
41 94
77 64
97 20
32 37
7 2
57 94
35 70
38 60
97 100
5 76
38 8
Sample Output 2
3 5 8 2 7 4 6 1