欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2109A.It's Time To Duel
It's Time To Duel
Something you may not know about Mouf is that he is a big fan of the Yu-Gi-Oh! card game. He loves to duel with anyone he meets. To gather all fans who love to play as well, he decided to organize a big Yu-Gi-Oh! tournament and invited players.
Mouf arranged the players in a line, numbered from to . They then held consecutive duels: for each from to , player faced player , producing one winner and one loser per match. Afterward, each player reports a value :
- indicating they won no duels;
- indicating they won at least one duel.
Since some may lie about their results (e.g., reporting a instead of a , or vice versa) to influence prize outcomes, Mouf will cancel the tournament if he can prove any report to be false.
Given the array , determine whether at least one player must be lying.
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 one integer () — the number of players in the tournament.
The second line of each test case contains integers () — denoting the report of the -th player.
Output
For each test case, print "YES" (without quotes) if there is at least one liar among the players, and "NO" (without quotes) 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 first test case, it is consistent if player defeats both players and , so nobody's report is necessarily false.
In the second test case, in the only match between players and , one must win — but both claimed zero wins, so someone must be lying.
In the third test case, the tournament consists of exactly one duel between players and — but it's impossible for both to win, concluding that at least one report is false.
In the fourth test case, a possible scenario is that player won against player , then won against , and then won against . All reports align, so there is no evidence that someone lied.
Samples
6
3
0 1 0
2
0 0
2
1 1
4
0 1 1 1
4
1 0 0 1
7
0 1 0 1 0 1 0
NO
YES
YES
NO
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |