102073: [AtCoder]ABC207 D - Congruence Points

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

You are given two sets $S=\{(a_1,b_1),(a_2,b_2),\ldots,(a_N,b_N)\}$ and $T=\{(c_1,d_1),(c_2,d_2),\ldots,(c_N,d_N)\}$ of $N$ points each on a two-dimensional plane.

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

  • Choose a real number $p\ (0 \lt p \lt 360)$ and rotate every point in $S$ $p$ degrees clockwise about the origin.
  • Choose real numbers $q$ and $r$ and move every point in $S$ by $q$ in the $x$-direction and by $r$ in the $y$-direction. Here, $q$ and $r$ can be any real numbers, be it positive, negative, or zero.

Constraints

  • $1 \leq N \leq 100$
  • $-10 \leq a_i,b_i,c_i,d_i \leq 10$
  • $(a_i,b_i) \neq (a_j,b_j)$ if $i \neq j$.
  • $(c_i,d_i) \neq (c_j,d_j)$ if $i \neq j$.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$
$a_1$ $b_1$
$a_2$ $b_2$
$\hspace{0.6cm}\vdots$
$a_N$ $b_N$
$c_1$ $d_1$
$c_2$ $d_2$
$\hspace{0.6cm}\vdots$
$c_N$ $d_N$

Output

If we can match $S$ with $T$, 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 $S$ and $T$ are painted red and green, respectively:

In this case, we can match $S$ with $T$ as follows:

  1. Rotate every point in $S$ $270$ degrees clockwise about the origin.
  2. Move every point in $S$ by $3$ in the $x$-direction and by $0$ in the $y$-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 $S$ and $T$ are symmetric about the $y$-axis, we cannot match $S$ with $T$ 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

Input

题意翻译

### 题意简述 在一个平面直角坐标系上,有两个点的集合 $S,T$ ,对于 $S$ , 我们采用${[a_1,b_1],[a_2,b_2],...,[a_n,b_n]}$ 表示 $S$ 中每个点的坐标 ,对于 $T$, 我们采用$[c_1,d_1],[c_2,d_2],...,[c_n,d_n]$ 表示 $T$ 中每个点的坐标 现在我们想要知道经过数次如下的操作(操作类型可自由选择,操作次数可为0)后,是否可使 $S, T$重合: - 任选一个实数$p(0<p\leq360)$,并将 $S$ 中的每个点围绕原点顺时针旋转 p度。 - 选择实数q和r,将S中的每个点在x方向上移动 $q$,在 $y$ 方向上移动 $r$ 。这里,$q$ 和 $r$ 可以是任何实数,无论是正数、负数还是零。 如果可使 $S, T$ 重合,输出 $Yes$, 否则,请输出 $No$. ### 样例说明: #### 样例一: ![](https://img.atcoder.jp/ghi/39ad67d4e10490f509f252a1f0e4935b.png) 在这种情况下,我们可以如下匹配 $S$ 和 $T$: 1. 围绕原点顺时针旋转 $S$ 中的每个点 $270$ 度。 2. 将 $S$ 中的每个点在 $x$ 方向上移动3,在 $y$ 方向上移动0。

加入题单

上一题 下一题 算法标签: