310207: CF1800A. Is It a Cat?

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Is It a Cat?

题意翻译

给定一个字符串及其长度,如果满足下列条件输出 ```YES``` 否则输出 ```NO```。 - 该字符串由四部分组成 - 每部分有且仅有一种字母(不分大小写),依次为 ```m```,```e```,```o```,```w```。 共 $t$ 组数据。 by @Larryyu

题目描述

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.

输入输出格式

输入格式


The first line of input data contains a single integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $ n $ ( $ 1 \le n \le 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.

输出格式


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).

输入输出样例

输入样例 #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.

Input

题意翻译

给定一个字符串及其长度,如果满足下列条件输出 ```YES``` 否则输出 ```NO```。 - 该字符串由四部分组成 - 每部分有且仅有一种字母(不分大小写),依次为 ```m```,```e```,```o```,```w```。 共 $t$ 组数据。 by @Larryyu

Output

**题意翻译**

给定一个字符串及其长度,如果满足以下条件输出 `YES` 否则输出 `NO`:
- 该字符串由四部分组成
- 每部分有且仅有一种字母(不分大小写),依次为 `m`、`e`、`o`、`w`。

共有 $t$ 组数据。

**题目描述**

你在街上走时听到了一个声音,这个声音可以用一个由小写和大写拉丁字母组成的字符串 $s$ 来描述。现在你想知道这个声音是否是猫的叫声。

为了使这个声音是猫的叫声,字符串只能包含字母 'm'、'e'、'o' 和 'w',无论大小写。同时满足以下条件:

- 字符串必须以仅由 'm' 或 'M' 组成的非空序列开始;
- 紧接着必须是一个仅由 'e' 或 'E' 组成的非空序列;
- 紧接着必须是一个仅由 'o' 或 'O' 组成的非空序列;
- 紧接着必须是一个仅由 'w' 或 'W' 组成的非空序列,这个序列是字符串的结尾。

例如,字符串 "meow"、"mmmEeOWww"、"MeOooOw" 描述的是猫的叫声,而 "Mweo"、"MeO"、"moew"、"MmEW"、"meowmeow" 不是。

确定你听到的声音是否是猫的叫声。

**输入输出格式**

**输入格式**

输入数据的第一行包含一个整数 $t$($1 \le t \le 10^4$)—— 测试用例的数量。

接下来是每个测试用例的描述。

每个测试用例的第一行包含一个整数 $n$($1 \le n \le 50$)—— 描述声音的字符串的长度。

每个测试用例的第二行包含一个由 $n$ 个字符组成的字符串 $s$。该字符串描述了你听到的声音,并且仅由小写和大写拉丁字母组成。

**输出格式**

对于每个测试用例,输出一行:

- 如果声音是猫的叫声,输出 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
```

**说明**

在第一个测试用例中,字符串由 'm'、'e'、'O'、'w' 的序列组成,符合猫叫声的定义。

在第二个测试用例中,字符串由 3 个 'm' 和 'M'、1 个 'e'、3 个 'o' 和 'O' 以及 7 个 'w' 和 'W' 的序列组成,符合猫叫声的定义。

在第三个测试用例中,字符串没有描述猫叫声,因为它在 'e' 和 'w' 之间缺少 'o' 或 'O' 的序列。

在第四个测试用例中,字符串包含字符 'U',所以它没有描述猫叫声。**题意翻译** 给定一个字符串及其长度,如果满足以下条件输出 `YES` 否则输出 `NO`: - 该字符串由四部分组成 - 每部分有且仅有一种字母(不分大小写),依次为 `m`、`e`、`o`、`w`。 共有 $t$ 组数据。 **题目描述** 你在街上走时听到了一个声音,这个声音可以用一个由小写和大写拉丁字母组成的字符串 $s$ 来描述。现在你想知道这个声音是否是猫的叫声。 为了使这个声音是猫的叫声,字符串只能包含字母 'm'、'e'、'o' 和 'w',无论大小写。同时满足以下条件: - 字符串必须以仅由 'm' 或 'M' 组成的非空序列开始; - 紧接着必须是一个仅由 'e' 或 'E' 组成的非空序列; - 紧接着必须是一个仅由 'o' 或 'O' 组成的非空序列; - 紧接着必须是一个仅由 'w' 或 'W' 组成的非空序列,这个序列是字符串的结尾。 例如,字符串 "meow"、"mmmEeOWww"、"MeOooOw" 描述的是猫的叫声,而 "Mweo"、"MeO"、"moew"、"MmEW"、"meowmeow" 不是。 确定你听到的声音是否是猫的叫声。 **输入输出格式** **输入格式** 输入数据的第一行包含一个整数 $t$($1 \le t \le 10^4$)—— 测试用例的数量。 接下来是每个测试用例的描述。 每个测试用例的第一行包含一个整数 $n$($1 \le n \le 50$)—— 描述声音的字符串的长度。 每个测试用例的第二行包含一个由 $n$ 个字符组成的字符串 $s$。该字符串描述了你听到的声音,并且仅由小写和大写拉丁字母组成。 **输出格式** 对于每个测试用例,输出一行: - 如果声音是猫的叫声,输出 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 ``` **说明** 在第一个测试用例中,字符串由 'm'、'e'、'O'、'w' 的序列组成,符合猫叫声的定义。 在第二个测试用例中,字符串由 3 个 'm' 和 'M'、1 个 'e'、3 个 'o' 和 'O' 以及 7 个 'w' 和 'W' 的序列组成,符合猫叫声的定义。 在第三个测试用例中,字符串没有描述猫叫声,因为它在 'e' 和 'w' 之间缺少 'o' 或 'O' 的序列。 在第四个测试用例中,字符串包含字符 'U',所以它没有描述猫叫声。

加入题单

算法标签: