P26956 [AtCoder] Symmetric Transformation
NOI
题目描述

Problem Description

Consider an infinitely expansive $xy$ plane.
You are given two sets of $N$ points on the plane, $S = \lbrace (x_1, y_1), (x_2, y_2), \ldots, (x_N, y_N) \rbrace$ and $T = \lbrace (X_1, Y_1), (X_2, Y_2), \ldots, (X_N, Y_N) \rbrace$.

You can perform either one of the following operations zero or one time:

  • Choose a line parallel to the $x$-axis and move each point in $S$ to its symmetric position with respect to the chosen line.
  • Choose a line parallel to the $y$-axis and move each point in $S$ to its symmetric position with respect to the chosen line.

Determine if it is possible to make set $S$ match set $T$ as a set.

Input Format

The input is given from the standard input in the following format:

$N$ $x_1$ $y_1$ $x_2$ $y_2$ $\vdots$ $x_N$ $y_N$ $X_1$ $Y_1$ $X_2$ $Y_2$ $\vdots$ $X_N$ $Y_N$

Output Format

Output Yes if it is possible to make set $S$ match set $T$ as a set, otherwise output No.

Sample Input and Output

Sample Input #1

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

Sample Output #1

Yes

Sample Input #2

2
1 1
0 0
0 0
-1 -1

Sample Output #2

No

Sample Input #3

3
3 1
4 1
5 9
5 9
3 1
4 1

Sample Output #3

Yes

Notes/Hints

Constraints

  • $1 \leq N \leq 2 \times 10^5$
  • $|x_i|, |y_i|, |X_i|, |Y_i| \leq 10^9$
  • $i \neq j \Rightarrow (x_i, y_i) \neq (x_j, y_j)$
  • $i \neq j \Rightarrow (X_i, Y_i) \neq (X_j, Y_j)$
  • All inputs are integers

Sample Explanation 1

$S = \lbrace (0, 1), (0, 3), (2, 3) \rbrace, T = \lbrace (1, 3), (-1, 3), (1, 1) \rbrace$. By choosing the line $x = 0.5$ parallel to the $y$-axis, each point in $S$ moves to $(0, 1) \rightarrow (1, 1), (0, 3) \rightarrow (1, 3), (2, 3) \rightarrow (-1, 3)$, making $S$ match $T$ as a set. Therefore, output Yes.

Sample Explanation 2

No matter what operation is performed, it is impossible to make $S$ match $T$ as a set. Therefore, output No. Note that only one of the two operations in the problem statement can be performed.

Sample Explanation 3

Without performing any operation, $S$ and $T$ already match as a set.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 3 0 3 0 1 -1 3 1 1 1 3
样例输出
Yes