#j. 1IXMMMlOP0xKWg#:)@|
1IXMMMlOP0xKWg#:)@|
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Statement
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?
Format
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.
Sample
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
ShanghaiTech ACM 炸鱼杯
- 状态
- 已结束
- 规则
- OI
- 题目
- 46
- 开始于
- 2024-12-10 23:00
- 结束于
- 2024-12-15 13:00
- 持续时间
- 110 小时
- 主持人
- 参赛人数
- 112