CF2217A.The Equalizer

入门

通过率:0%

AC君温馨提醒

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

题目描述

To settle a long-time feud, Shaunak and Yash decided to play a game on an array $ a $ of $ n $ integers, with Shaunak going first. The players take turns, and the last player to make a move wins. On a player's turn, he chooses some $ a_i \gt 0 $ and decrements it by $ 1 $ .

To make things interesting, Shaunak is allowed to use a special move at most once during the game. This move replaces his normal turn. When used, all elements $ a_i $ ( $ 1 \leq i \leq n $ ) are set to a special value $ k $ that is given initially.

Assuming that both players play optimally, determine if Shaunak can always win.

输入格式

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

The first line of each test case contains two integers $ n $ and $ k $ ( $ 1 \leq n \leq 100 $ , $ 1 \leq k \leq 500 $ ), denoting the size of the array and the special value.

The second line contains $ n $ integers $ a_1,a_2,\ldots,a_n $ ( $ 1 \leq a_i \leq 10^3 $ ).

输出格式

For each test case, print "YES" if Shaunak can always win, and "NO" otherwise.

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.

输入输出样例

  • 输入#1

    4
    1 1
    1
    2 67
    67 67
    3 2
    3 3 3
    11 3
    1 2 3 4 5 6 7 8 9 10 11

    输出#1

    YES
    YES
    YES
    NO

说明/提示

In the third test case, $ n = 3 $ , $ k = 2 $ and the initial array is $ [3, 3, 3] $ . One possible way the game could proceed is shown:

  • Shaunak decrements $ a_3 $ . Array becomes $ [3, 3, 2] $ .
  • Yash decrements $ a_3 $ . Array becomes $ [3, 3, 1] $ .
  • Shaunak uses the special move. Array becomes $ [2, 2, 2] $ .
  • Yash decrements $ a_1 $ . Array becomes $ [1, 2, 2] $ .
  • Shaunak decrements $ a_2 $ . Array becomes $ [1, 1, 2] $ .
  • Yash decrements $ a_3 $ . Array becomes $ [1, 1, 1] $ .
  • Shaunak decrements $ a_1 $ . Array becomes $ [0, 1, 1] $ .
  • Yash decrements $ a_3 $ . Array becomes $ [0, 1, 0] $ .
  • Shaunak decrements $ a_2 $ . Array becomes $ [0, 0, 0] $ .

Since there are no $ a_i \gt 0 $ remaining, Yash cannot make any further moves and Shaunak wins.

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

首页