欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2028A.Alice's Adventures in "Chess"
Alice's Adventures in "Chess"
Alice is trying to meet up with the Red Queen in the countryside! Right now, Alice is at position , and the Red Queen is at position . Alice can only move in the four cardinal directions (north, east, south, west).
More formally, if Alice is at the point , she will do one of the following:
- go north (represented by
N), moving to ; - go east (represented by
E), moving to ; - go south (represented by
S), moving to ; or - go west (represented by
W), moving to .
Alice's movements are predetermined. She has a string representing a sequence of moves that she performs from left to right. Once she reaches the end of the sequence, she repeats the same pattern of moves forever.
Can you help Alice figure out if she will ever meet the Red Queen?
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 length of the string and the initial coordinates of the Red Queen.
The second line contains a string of length consisting only of the characters N, E, S, or W.
Output
For each test case, output a single string "YES" or "NO" (without the quotes) denoting whether Alice will eventually meet the Red Queen.
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, Alice follows the path $(0,0) \xrightarrow[\texttt{N}]{} (0,1) \xrightarrow[\texttt{E}]{} (1,1) \xrightarrow[\texttt{N}]{} (1,2) \xrightarrow[\texttt{E}]{} (2,2)$.
In the second test case, Alice can never reach the Red Queen.
Samples
6
2 2 2
NE
3 2 2
NNE
6 2 1
NNEESW
6 10 10
NNEESW
3 4 2
NEE
4 5 5
NEWS
YES
NO
YES
YES
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |