欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1451B.Non-Substring Subsequence
Non-Substring Subsequence
Hr0d1y has queries on a binary string of length . A binary string is a string containing only characters '0' and '1'.
A query is described by a pair of integers , .
For each query, he has to determine whether there exists a good subsequence in that is equal to the substring .
- A substring of a string is the string formed by characters .
- String is said to be a subsequence of string if can be obtained from by deleting some characters without changing the order of the remaining characters.
- A subsequence is said to be good if it is not contiguous and has length . For example, if is "
1100110", then the subsequences ("1100110") and ("1100110") are good, while ("1100110") is not good.
Can you help Hr0d1y answer each query?
Input
The first line of the input contains a single integer () — the number of test cases. The description of each test case is as follows.
The first line contains two integers () and () — the length of the string and the number of queries.
The second line contains the string .
The -th of the next lines contains two integers and ().
Output
For each test case, output lines. The -th line of the output of each test case should contain "YES" if there exists a good subsequence equal to the substring , and "NO" otherwise.
You may print each letter in any case (upper or lower).
Note
In the first test case,
- "
010". In this case ("001000") and ("001000") are good suitable subsequences, while ("001000") is not good. - "
001". No suitable good subsequence exists. - "
100". Here ("001000") is a suitable good subsequence.
Samples
2
6 3
001000
2 4
1 3
3 5
4 2
1111
1 4
2 3
YES
NO
YES
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |