欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2055A.Two Frogs
Two Frogs
| Roaming through the alligator-infested Everglades, Florida Man encounters a most peculiar showdown. |
|---|
There are lilypads arranged in a row, numbered from to from left to right. Alice and Bob are frogs initially positioned on distinct lilypads, and , respectively. They take turns jumping, starting with Alice.
During a frog's turn, it can jump either one space to the left or one space to the right, as long as the destination lilypad exists. For example, on Alice's first turn, she can jump to either lilypad or , provided these lilypads are within bounds. It is important to note that each frog must jump during its turn and cannot remain on the same lilypad.
However, there are some restrictions:
- The two frogs cannot occupy the same lilypad. This means that Alice cannot jump to a lilypad that Bob is currently occupying, and vice versa.
- If a frog cannot make a valid jump on its turn, it loses the game. As a result, the other frog wins.
Determine whether Alice can guarantee a win, assuming that both players play optimally. It can be proven that the game will end after a finite number of moves if both players play optimally.
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 and only line of each test case contains three integers , , and (, , ) — the number of lilypads, and the starting positions of Alice and Bob, respectively.
Note that there are no constraints on the sum of over all test cases.
Output
For each test case, print a single line containing either "YES" or "NO", representing whether or not Alice has a winning strategy.
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 first test case, Alice has no legal moves. Therefore, Alice loses on the first turn.
In the second test case, Alice can only move to lilypad . Then, Bob has no legal moves. Therefore, Alice has a winning strategy in this case.
In the third test case, Alice can only move to lilypad . Then, Bob can move to lilypad . Alice is no longer able to move and loses, giving Bob the win. It can be shown that Bob can always win regardless of Alice's moves; hence, Alice does not have a winning strategy.
Samples
5
2 1 2
3 3 1
4 2 3
5 2 4
7 6 2
NO
YES
NO
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |