QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#17414. 点镜像

统计

数轴上有 $N$ 个点。最初,第 $i$ 个点位于坐标 $A_i$ 处。

你可以按任意顺序执行以下操作任意次数:

  • 选择两个不同的点 $i$ 和 $j$,并交换它们。
  • 选择两个不同的点 $i$ 和 $j$,并将点 $i$ 关于点 $j$ 对称移动。形式化地,设 $A_i := 2A_j - A_i$。

是否可能在所有操作后,对于所有 $1 \le i \le N$,第 $i$ 个点都位于 $B_i$ 处?

输入格式

输入按以下格式给出:

T
N
A_1 B_1
A_2 B_2
:
A_N B_N
:
  • 所有输入值均为整数。
  • $1 \le T \le 10^4$
  • $1 \le N \le 2 \times 10^5$
  • $-10^9 \le A_i, B_i \le 10^9$
  • 保证所有测试用例中 $N$ 的总和不超过 $2 \times 10^5$。

输出格式

对于每个测试用例,如果可以达到目标最终配置,则输出 YES,否则输出 NO

你可以输出任意大小写的答案。例如,字符串 YESyesyEs 都将被视为肯定的回答。

样例

输入样例 1

6
1
1 1
1
0 2
2
0 3
1 2
2
1 5
2 7
3
-3 5
9 13
7 5
3
-3 11
9 25
7 9

输出样例 1

YES
NO
YES
NO
NO
YES

说明

测试用例 3:一种有效的操作序列为:

  1. 从坐标 $[0, 1]$ 开始。
  2. 将点 1 关于点 2 对称移动。坐标变为 $[2, 1]$。
  3. 交换点 1 和点 2。坐标变为 $[1, 2]$。
  4. 将点 1 关于点 2 对称移动。坐标变为 $[3, 2]$。

测试用例 2、4 和 5:可以证明无法使点达到目标坐标。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.