欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1462B.Last Year's Substring
Last Year's Substring
Polycarp has a string of length consisting of decimal digits. Polycarp performs the following operation with the string no more than once (i.e. he can perform operation or time):
- Polycarp selects two numbers and () and removes characters from the string at the positions (i.e. removes substring ). More formally, Polycarp turns the string into the string $s_1 s_2 \ldots s_{i-1} s_{j+1} s_{j+2} \ldots s_{n}$.
For example, the string "20192020" Polycarp can turn into strings:
- "
2020" (in this case or ); - "
2019220" (in this case ); - "
020" (in this case ); - other operations are also possible, only a few of them are listed above.
Polycarp likes the string "2020" very much, so he is wondering if it is possible to turn the string into a string "2020" in no more than one operation? Note that you can perform zero operations.
Input
The first line contains a positive integer () — number of test cases in the test. Then test cases follow.
The first line of each test case contains an integer () — length of the string . The next line contains a string of length consisting of decimal digits. It is allowed that the string starts with digit 0.
Output
For each test case, output on a separate line:
- "
YES" if Polycarp can turn the string into a string "2020" in no more than one operation (i.e. he can perform or operation); - "
NO" otherwise.
You may print every letter of "YES" and "NO" in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).
Note
In the first test case, Polycarp could choose and .
In the second test case, Polycarp could choose and .
In the third test case, Polycarp did not perform any operations with the string.
Samples
6
8
20192020
8
22019020
4
2020
5
20002
6
729040
6
200200
YES
YES
YES
NO
NO
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |