CF1800A.Is It a Cat?
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You were walking down the street and heard a sound. The sound was described by the string s 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.
你正走在街上,听到一个声音。这个声音由字符串 s 描述,其中只包含小写和大写的拉丁字母。现在你想判断这个声音是否是一只猫在喵喵叫。
该声音要被视为“喵叫”,字符串 s 必须仅包含字母 'm'、'e'、'o' 和 'w'(大小写均可),并且还需满足以下条件:
- 字符串必须以一个非空的字符序列开头,该序列中只包含字符
'm'或'M'; - 其后必须紧跟着一个非空的字符序列,该序列中只包含字符
'e'或'E'; - 其后必须紧跟着一个非空的字符序列,该序列中只包含字符
'o'或'O'; - 其后必须紧跟着一个非空的字符序列,该序列中只包含字符
'w'或'W';该序列必须恰好位于字符串末尾,其后立即为字符串结束。
例如,字符串 "meow"、"mmmEeOWww"、"MeOooOw" 均表示一次喵叫;但字符串 "Mweo"、"MeO"、"moew"、"MmEW"、"meowmeow" 则不是。
请判断你所听到的声音是否是一只猫在喵喵叫,还是其他声音。
输入格式
The first line of input data contains a single integer t (1≤t≤104) — the number of test cases.
The description of the test cases follows.
The first line of each test case contains an integer n (1≤n≤50) — the length of the string describing the sound.
The second line of each test case contains a string s of n characters. The string describes the sound you heard and consists only of lowercase and uppercase Latin letters.
输入数据的第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。
接下来是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤50)—— 描述声音的字符串长度。
每个测试用例的第二行包含一个长度为 n 的字符串 s。该字符串描述了你听到的声音,且仅由小写和大写拉丁字母组成。
输出格式
For each test case, output on a separate line:
- YES if the sound was a cat meowing;
- NO otherwise.
You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as positive response).
对于每个测试用例,在单独的一行上输出:
- 如果该声音是猫的喵喵叫,则输出
YES; - 否则输出
NO。
YES 和 NO 的大小写不限(例如,字符串 yEs、yes、Yes 和 YES 均被视为肯定回答)。
输入输出样例
输入#1
7 4 meOw 14 mMmeoOoWWWwwwW 3 mew 7 MmeEeUw 4 MEOW 6 MmyaVW 5 meowA
输出#1
YES YES NO NO YES NO NO
说明/提示
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 3 characters 'm' and 'M', one 'e', a sequence of 3 characters 'o' and 'O' and a sequence of 7 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.
在第一个测试用例中,该字符串由字符序列 'm'、'e'、'O'、'w' 组成,满足“喵叫”(meowing)的定义。
在第二个测试用例中,该字符串由 3 个字符 'm' 和 'M' 组成的序列、一个 'e'、由 3 个字符 'o' 和 'O' 组成的序列,以及由 7 个字符 'w' 和 'W' 组成的序列构成,满足“喵叫”(meowing)的定义。
在第三个测试用例中,该字符串不表示一次“喵叫”,因为它在 'e' 和 'w' 之间缺少 'o' 或 'O' 字符组成的序列。
在第四个测试用例中,该字符串包含字符 'U',因此它不表示一次“喵叫”。
输入解题思路,AI测评打分。不知道怎么写?