Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 256 MB 總分: 100 难度: [顯示] 可 Hack ✓
统计

给定两个数组 $a_1, a_2, \dots, a_n$ 和 $b_1, b_2, \dots, b_m$,满足 $n+m = 2k$。两个数组中的所有值都在 $1$ 到 $k$ 之间。从 $1$ 到 $k$ 的每个值在数组中恰好出现两次,这两次出现可能在同一个数组中,也可能在不同的数组中。

两名玩家进行游戏。在每一步中,玩家可以从任一数组的末尾取走一个元素。当所有元素都被取走时游戏结束。如果第二名玩家取走的所有元素互不相同,则第二名玩家获胜;否则,第一名玩家获胜。确定哪名玩家拥有必胜策略。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 10^5$),表示测试用例的数量。接下来是各测试用例的描述。

每个测试用例的第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 5 \cdot 10^5$),分别表示两个数组的长度。

每个测试用例的第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le \frac{n+m}{2}$),表示第一个数组的元素。

每个测试用例的第三行包含 $m$ 个整数 $b_1, b_2, \dots, b_m$ ($1 \le b_i \le \frac{n+m}{2}$),表示第二个数组的元素。

从 $1$ 到 $\frac{n+m}{2}$ 的每个值在数组中恰好出现两次。

保证所有测试用例中 $n+m$ 的总和不超过 $10^6$。

输出格式

对于每个测试用例,如果第一名玩家获胜,输出 1,否则输出 2。

样例

样例输入 1

4
1 3
1
1 2 2
3 3
1 2 3
2 3 1
2 4
3 1
2 3 1 2
2 2
1 2
1 2

样例输出 1

2
1
2
2

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.