欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2217A.The Equalizer
The Equalizer
To settle a long-time feud, Shaunak and Yash decided to play a game on an array of 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 and decrements it by .
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 () are set to a special value that is given initially.
Assuming that both players play optimally, determine if Shaunak can always win.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and (, ), denoting the size of the array and the special value.
The second line contains integers ().
Output
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.
Note
In the third test case, , and the initial array is . One possible way the game could proceed is shown:
- Shaunak decrements . Array becomes .
- Yash decrements . Array becomes .
- Shaunak uses the special move. Array becomes .
- Yash decrements . Array becomes .
- Shaunak decrements . Array becomes .
- Yash decrements . Array becomes .
- Shaunak decrements . Array becomes .
- Yash decrements . Array becomes .
- Shaunak decrements . Array becomes .
Since there are no remaining, Yash cannot make any further moves and Shaunak wins.
Samples
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
YES
YES
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |