欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1800A.Is It a Cat?
Is It a Cat?
You were walking down the street and heard a sound. The sound was described by the string consisting of lowercase and uppercase Latin characters. Now you want to find out if the sound was a cat meowing.
For the sound to be a meowing, the string can only contain the letters 'm', 'e', 'o' and 'w', in either uppercase or lowercase. Also:
- string must start with non-empty sequence consisting only of characters '
m' or 'M' - it must be immediately followed by non-empty sequence consisting only of characters '
e' or 'E' - it must be immediately followed by non-empty sequence consisting only of characters '
o' or 'O' - it must be immediately followed by non-empty sequence consisting only of characters '
w' or 'W', this sequence ends the string, after it immediately comes the string end
For example, strings "meow", "mmmEeOWww", "MeOooOw" describe a meowing, but strings "Mweo", "MeO", "moew", "MmEW", "meowmeow" do not.
Determine whether the sound you heard was a cat meowing or something else.
Input
The first line of input data contains a single integer () — the number of test cases.
The description of the test cases follows.
The first line of each test case contains an integer () — the length of the string describing the sound.
The second line of each test case contains a string of characters. The string describes the sound you heard and consists only of lowercase and uppercase Latin letters.
Output
For each test case, output on a separate line:
YESif the sound was a cat meowing;NOotherwise.
You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as positive response).
Note
In the first test case, the string consists of a sequence of characters 'm', 'e', 'O', 'w', which satisfies the definition of meowing.
In the second test case, the string consists of a sequence of characters 'm' and 'M', one 'e', a sequence of characters 'o' and 'O' and a sequence of characters 'w' and 'W', which satisfies the definition of meowing.
In the third test case, the string does not describe a meowing because it lacks a sequence of 'o' or 'O' characters between 'e' and 'w'.
In the fourth test case, the string contains the character 'U', so it does not describe a meowing.
Samples
7
4
meOw
14
mMmeoOoWWWwwwW
3
mew
7
MmeEeUw
4
MEOW
6
MmyaVW
5
meowA
YES
YES
NO
NO
YES
NO
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |