#abc207d. D - Congruence Points

D - Congruence Points

Score : 400400 points

问题描述

给定两个集合 S={(a1,b1),(a2,b2),,(aN,bN)}S=\{(a_1,b_1),(a_2,b_2),\ldots,(a_N,b_N)\}T={(c1,d1),(c2,d2),,(cN,dN)}T=\{(c_1,d_1),(c_2,d_2),\ldots,(c_N,d_N)\},每个集合包含二维平面上的 NN 个点。

确定是否可以按照任意顺序对集合 SS 进行任意次数(包括零次)以下操作,使得 SSTT 匹配:

  • 选择一个实数 p (0<p<360)p\ (0 \lt p \lt 360),将 SS 中的所有点绕原点顺时针旋转 pp 度。
  • 选择实数 qqrr,将 SS 中的所有点沿 xx 轴方向移动 qq,沿 yy 轴方向移动 rr。这里的 qqrr 可以为任何实数,无论是正数、负数或零。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given two sets S={(a1,b1),(a2,b2),,(aN,bN)}S=\{(a_1,b_1),(a_2,b_2),\ldots,(a_N,b_N)\} and T={(c1,d1),(c2,d2),,(cN,dN)}T=\{(c_1,d_1),(c_2,d_2),\ldots,(c_N,d_N)\} of NN points each on a two-dimensional plane.

Determine whether it is possible to do the following operations on SS any number of times (possibly zero) in any order so that SS matches TT.

  • Choose a real number p (0<p<360)p\ (0 \lt p \lt 360) and rotate every point in SS pp degrees clockwise about the origin.
  • Choose real numbers qq and rr and move every point in SS by qq in the xx-direction and by rr in the yy-direction. Here, qq and rr can be any real numbers, be it positive, negative, or zero.

Constraints

  • 1N1001 \leq N \leq 100
  • 10ai,bi,ci,di10-10 \leq a_i,b_i,c_i,d_i \leq 10
  • (ai,bi)(aj,bj)(a_i,b_i) \neq (a_j,b_j) if iji \neq j.
  • (ci,di)(cj,dj)(c_i,d_i) \neq (c_j,d_j) if iji \neq j.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

a1a_1 b1b_1

a2a_2 b2b_2

\hspace{0.6cm}\vdots

aNa_N bNb_N

c1c_1 d1d_1

c2c_2 d2d_2

\hspace{0.6cm}\vdots

cNc_N dNd_N

Output

If we can match SS with TT, print Yes; otherwise, print No.

Sample Input 1

3
0 0
0 1
1 0
2 0
3 0
3 1

Sample Output 1

Yes

The figure below shows the given sets of points, where the points in SS and TT are painted red and green, respectively:

In this case, we can match SS with TT as follows:

  1. Rotate every point in SS 270270 degrees clockwise about the origin.
  2. Move every point in SS by 33 in the xx-direction and by 00 in the yy-direction.

Sample Input 2

3
1 0
1 1
3 0
-1 0
-1 1
-3 0

Sample Output 2

No

The figure below shows the given sets of points:

Although SS and TT are symmetric about the yy-axis, we cannot match SS with TT by rotations and translations as stated in Problem Statement.

Sample Input 3

4
0 0
2 9
10 -2
-6 -7
0 0
2 9
10 -2
-6 -7

Sample Output 3

Yes

Sample Input 4

6
10 5
-9 3
1 -5
-6 -5
6 9
-9 0
-7 -10
-10 -5
5 4
9 0
0 -10
-10 -2

Sample Output 4

Yes

update @ 2024/3/10 09:20:53