DeepInfra Round 1(Codeforces Round 1126,Div. 1 + Div. 2)
B
MEX 游戏
MEX Game
Codeforces
1000
原题
← AC →

MEX 游戏AI (CI翻译)

For a multiset $\mathcal{S}$ and a positive integer $k$, let $\operatorname{mex}_k(\mathcal{S})$ be the smallest non-negative integer that appears in $\mathcal{S}$ fewer than $k$ times. In particular, $\operatorname{mex}_1(\mathcal{S})$ is the usual $\operatorname{mex}$$^{\text{∗}}$ of $\mathcal{S}$.

对于一个多重集合 $\mathcal{S}$ 和正整数 $k$,令 $\operatorname{mex}_k(\mathcal{S})$ 表示在 $\mathcal{S}$ 中出现次数少于 $k$ 次的最小非负整数。特别地,$\operatorname{mex}_1(\mathcal{S})$ 就是 $\mathcal{S}$ 的通常的 $\operatorname{mex}$$^{\text{∗}}$。AI (CI翻译)

For example:

例如:AI (CI翻译)

  • $\operatorname{mex}_1(\{0, 1, 1, 2\}) = 3$;
  • $\operatorname{mex}_2(\{0, 0, 1, 1, 1, 3\}) = 2$;
  • $\operatorname{mex}_2(\{0, 1, 1, 2\}) = 0$;
  • $\operatorname{mex}_2(\{0, 0, 1, 2\}) = 1$.
  • $\operatorname{mex}_1(\{0, 1, 1, 2\}) = 3$;
  • $\operatorname{mex}_2(\{0, 0, 1, 1, 1, 3\}) = 2$;
  • $\operatorname{mex}_2(\{0, 1, 1, 2\}) = 0$;
  • $\operatorname{mex}_2(\{0, 0, 1, 2\}) = 1$。
AI (CI翻译)

You are given an even integer $n$, a positive integer $k$, and $n$ cards. The integer $a_i$ is written on the $i$-th card.

给定一个偶数 $n$、一个正整数 $k$ 以及 $n$ 张卡片。第 $i$ 张卡片上写有整数 $a_i$。AI (CI翻译)

Alice and Bob play the following game with these cards. Alice moves first, and the players alternate turns. On each turn, the current player takes any one of the remaining cards. The game ends when all $n$ cards have been taken, so each player ends up with exactly $\dfrac{n}{2}$ cards.

Alice 和 Bob 使用这些卡片进行如下游戏。Alice 先手,双方轮流行动。每次行动时,当前玩家从剩余卡片中任意取走一张。所有 $n$ 张卡片都被取走后游戏结束,此时每位玩家恰好拥有 $\dfrac{n}{2}$ 张卡片。AI (CI翻译)

Let $\mathcal{A}$ be the multiset of integers written on Alice's cards, and let $\mathcal{B}$ be the multiset of integers written on Bob's cards. Alice wins if $\operatorname{mex}_k(\mathcal{A}) \ne \operatorname{mex}_k(\mathcal{B})$, and Bob wins otherwise.

令 $\mathcal{A}$ 表示 Alice 所持卡片上整数构成的多重集合,令 $\mathcal{B}$ 表示 Bob 所持卡片上整数构成的多重集合。如果 $\operatorname{mex}_k(\mathcal{A}) \ne \operatorname{mex}_k(\mathcal{B})$,则 Alice 获胜;否则 Bob 获胜。AI (CI翻译)

Determine whether Alice wins if both players play optimally.

假设双方都采取最优策略,判断 Alice 是否获胜。AI (CI翻译)

$^{\text{∗}}$The minimum excluded (MEX) of a collection of integers $c_1, c_2, \ldots, c_m$ is defined as the smallest non-negative integer $x$ which does not occur in the collection $c$.

$^{\text{∗}}$整数集合 $c_1, c_2, \ldots, c_m$ 的最小未出现值(MEX)定义为集合 $c$ 中未出现的最小非负整数 $x$。AI (CI翻译)

Input

输入格式

AI (CI翻译)

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

每个测试包含多个测试用例。第一行包含测试用例数量 $t$($1 \le t \le 10^4$)。接下来描述各个测试用例。AI (CI翻译)

The first line of each test case contains two integers $n$ and $k$ ($2 \le n \le 2 \cdot 10^5$, $n$ is even, $1 \le k \le n$) — the number of cards and the parameter of the game.

每个测试用例的第一行包含两个整数 $n$ 和 $k$($2 \le n \le 2 \cdot 10^5$,$n$ 为偶数,$1 \le k \le n$),分别表示卡片数量和游戏参数。AI (CI翻译)

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le n$) — the integers written on the cards.

每个测试用例的第二行包含 $n$ 个整数 $a_1, a_2, \ldots, a_n$($0 \le a_i \le n$),表示卡片上写的整数。AI (CI翻译)

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

保证所有测试用例的 $n$ 之和不超过 $2 \cdot 10^5$。AI (CI翻译)

Output

输出格式

AI (CI翻译)

For each test case, output "YES" if Alice wins, and "NO" otherwise.

对于每个测试用例,如果 Alice 获胜,输出“YES”;否则输出“NO”。AI (CI翻译)

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

输出答案时可以使用任意大小写形式。例如,字符串“yEs”、“yes”、“Yes”和“YES”都会被识别为肯定回答。AI (CI翻译)

Note

说明

AI (CI翻译)

In the first example, Alice can take the card showing $1$ on her first turn and a card showing $0$ on her second turn. Then $\mathcal{A} = \{0, 1\}$ and $\mathcal{B} = \{0, 2\}$, so $\operatorname{mex}_1(\mathcal{A}) = 2$ and $\operatorname{mex}_1(\mathcal{B}) = 1$. It can be proven that Alice wins regardless of Bob's moves, so the answer is "YES".

在第一个样例中,Alice 可以在第一回合取走写有 $1$ 的卡片,并在第二回合取走写有 $0$ 的卡片。此时 $\mathcal{A} = \{0, 1\}$,$\mathcal{B} = \{0, 2\}$,因此 $\operatorname{mex}_1(\mathcal{A}) = 2$,$\operatorname{mex}_1(\mathcal{B}) = 1$。可以证明,无论 Bob 如何行动,Alice 都能获胜,因此答案是“YES”。AI (CI翻译)

In the second example, the players can take cards in the following order: Alice takes $1$, Bob takes $1$, Alice takes $0$, and Bob takes $0$. Then $\mathcal{A} = \mathcal{B} = \{0, 1\}$ and $\operatorname{mex}_1(\mathcal{A}) = \operatorname{mex}_1(\mathcal{B}) = 2$. It can be proven that Bob wins if both players play optimally, so the answer is "NO".

在第二个样例中,双方可以按照以下顺序取牌:Alice 取走 $1$,Bob 取走 $1$,Alice 取走 $0$,Bob 取走 $0$。此时 $\mathcal{A} = \mathcal{B} = \{0, 1\}$,且 $\operatorname{mex}_1(\mathcal{A}) = \operatorname{mex}_1(\mathcal{B}) = 2$。可以证明,当双方都采取最优策略时,Bob 能够获胜,因此答案是“NO”。AI (CI翻译)

样例

Input #1
5
4 1
2 0 0 1
4 1
0 1 0 1
6 2
1 2 0 1 0 0
6 2
0 0 1 1 2 2
8 2
0 1 1 0 0 2 0 1
Output #1
YES
NO
YES
NO
YES
InputCopy OutputCopy
题目信息
题号
2271B
时间限制
1.5 s
内存限制
256 MB
标签
博弈论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。