欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2157B.Expansion Plan 2
Expansion Plan 2
ak+q - over the crimson skies⠀
You are analyzing an infinite grid with coordinates (specifically, the cell immediately above is , and the cell immediately on the right of is ). Initially, only the cell at is black.
You are given a string of length consisting of characters "4" and "8", which describes expansion operations. For each from to , the following happens for all cells simultaneously:
- if : for each cell, if it is orthogonally adjacent to a black cell (i.e., it shares a side), it becomes black; otherwise, its state remains the same;
- if : for each cell, if it is orthogonally or diagonally adjacent to a black cell (i.e, it shares a side or a corner), it becomes black; otherwise, its state remains the same.
Is the cell black at the end of the process?
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 three integers , , () — the number of expansion operations, and the and coordinates of the cell you are interested in, respectively.
The second line of each test case contains a string of length consisting of characters "4" and "8" — the types of expansion operations.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output YES if the cell is black after the expansion operations described by the string , and NO otherwise.
The judge is case-insensitive (for example, YES, Yes, yes, yEs will all be recognized as positive answers).
Note
The first three test cases are illustrated below:

In the first test case, after the expansion operations in the string "888", cell is black, so the answer is YES.
In the second test case, cell is white after the expansion operations in the string "4884".
Samples
6
3 3 3
888
4 5 1
4884
4 3 -3
4884
7 -7 -5
4884884
10 0 0
4884884888
1 1 1
4
YES
NO
YES
NO
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |