CF2236D.Brand New Tatar TV Show

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Dabir and Egor were not satisfied with the fame from the previous episode, so they decided to make another TV show: the guys play their favorite game on an array aa with their favorite integer kk.

Dabir moves first. On the first move, any element from the array can be chosen and removed. Let the previous chosen element be equal to xx. Then on the current move, except the very first one, a player must choose an element yy from the array such that 0≤y−x≤k0 \leq y - x \leq k and remove it from the array. The player who cannot make a move loses.

But since this was not just a game, but a real show-match, Arseniy (aka MAKAN) — the main celebrity of Omsk was invited again. As a guest celebrity, Arseniy was given the opportunity to make the first move in this match, that is, to make the very first move in the game instead of Dabir. However, it turns out Arseniy is a fan of Egor, so he wants his first move to guarantee Egor a winning strategy against any response from Dabir.

Determine whether Arseniy can make the first move for Dabir so that, no matter how Dabir plays, Egor wins.

达比尔和叶戈尔对上一集获得的名气并不满足,于是他们决定再制作一档电视节目:两人在数组 aa 上,使用他们最爱的整数 kk,玩他们最钟爱的游戏。

达比尔先手。在第一步中,可以从数组中任选一个元素并将其移除。设上一次被选中的元素为 xx。那么,在当前步(除第一步外),玩家必须从数组中选择一个元素 yy,满足 0≤y−x≤k0 \leq y - x \leq k,并将其从数组中移除。无法进行合法操作的玩家判负。

但由于这不仅是一场游戏,更是一场真实的节目对决,奥姆斯克的头号明星阿尔谢尼(即 MAKAN)再次受邀出席。作为特邀明星,阿尔谢尼获得了本次对决的先手权,即代替达比尔执先手、进行游戏的第一步。然而,阿尔谢尼其实是叶戈尔的粉丝,因此他希望自己的第一步能确保:无论达比尔后续如何应对,叶戈尔都拥有必胜策略。

请判断:阿尔谢尼能否为达比尔代为执先手,使得无论达比尔如何应对,叶戈尔均必胜?

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt (1≤t≤1041 \leq t \leq 10^4) — the number of test cases.

The first line of each test case contains two integers nn and kk (1≤n,k≤2⋅1051 \leq n, k \leq 2 \cdot 10^5) — the length of the array and the favorite integer of Dabir and Egor.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤n1 \leq a_i \leq n).

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

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤1041 \leq t \leq 10^4),表示测试用例的数量。

每个测试用例的第一行包含两个整数 nn 和 kk(1≤n,k≤2⋅1051 \leq n, k \leq 2 \cdot 10^5),分别表示数组的长度以及 Dabir 和 Egor 最喜欢的整数。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤n1 \leq a_i \leq n)。

保证所有测试用例中 nn 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, if there exists such a first move that with optimal play by both players Egor wins, output "YES", otherwise output "NO".

You can output "YES" and "NO" in any case (for example, "yES", "yes", and "Yes" will be accepted).

对于每个测试用例,如果存在某个先手操作,使得双方均采取最优策略时 Egor 获胜,则输出 "YES";否则输出 "NO"。

你可以以任意大小写形式输出 "YES" 和 "NO"(例如,"yES"、"yes" 和 "Yes" 均可被接受)。

输入输出样例

  • 输入#1

    7
    5 1
    3 3 3 3 3
    3 1
    1 1 2
    2 2
    2 1
    4 1
    3 3 3 3
    4 3
    2 2 2 1
    4 1
    1 3 1 1
    5 1
    5 1 5 1 5

    输出#1

    NO
    YES
    YES
    YES
    YES
    NO
    YES

说明/提示

In the first example, the only possible option is to choose the integer 33. After that, the array [3,3,3,33, 3, 3, 3] remains. Then Egor moves, then Dabir, and so on. Dabir will take the last 33, so Arseniy cannot choose a first move that makes Egor win.

In the second example, Arseniy can choose the integer 11 as the first move. Then Egor will choose the integer 22, and Dabir will have no valid moves left, so Egor wins.

在第一个例子中,唯一可能的选择是选取整数 33。此后,数组变为 [3,3,3,33, 3, 3, 3]。接着由 Egor 行动,然后是 Dabir,依此类推。Dabir 将取走最后一个 33,因此 Arseniy 无法通过第一步操作使得 Egor 获胜。

在第二个例子中,Arseniy 可以第一步选择整数 11。随后 Egor 将选择整数 22,而 Dabir 将不再有合法操作可选,因此 Egor 获胜。

输入解题思路,AI测评打分。不知道怎么写?

首页