欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1499B.Binary Removals
Binary Removals
You are given a string , consisting only of characters '0' or '1'. Let be the length of .
You are asked to choose some integer () and find a sequence of length such that:
- ;
- for all from to .
The characters at positions are removed, the remaining characters are concatenated without changing the order. So, in other words, the positions in the sequence should not be adjacent.
Let the resulting string be . is called sorted if for all from to .
Does there exist such a sequence that the resulting string is sorted?
Input
The first line contains a single integer () — the number of testcases.
Then the descriptions of testcases follow.
The only line of each testcase contains a string (). Each character is either '0' or '1'.
Output
For each testcase print "YES" if there exists a sequence such that removing the characters at positions and concatenating the parts without changing the order produces a sorted string.
Otherwise, print "NO".
You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).
Note
In the first testcase you can choose a sequence . Removing the underlined letters from "10101011011" will produce a string "0011111", which is sorted.
In the second and the third testcases the sequences are already sorted.
In the fourth testcase you can choose a sequence . "11", which is sorted.
In the fifth testcase there is no way to choose a sequence such that is sorted.
Samples
5
10101011011
0000
11111
110
1100
YES
YES
YES
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |