Universal Cup Judging System

Universal Cup

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

数直線上に $N$ 個の点があります。最初、$i$ 番目の点は座標 $A_i$ にあります。

あなたは次の操作を任意の順序で何回でも行うことができます:

  • 異なる 2 つの点 $i$ と $j$ を選び、それらを入れ替える。
  • 異なる 2 つの点 $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 を出力してください。

答えは大文字・小文字を問わず出力できます。例えば、文字列 YES、yes、yEs はいずれも肯定の応答として認識されます。

入出力例

入力例 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 つは以下の通りです:

  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.