A. Romaji

Codeforces
IDCF1008A
Time2000ms
Memory256MB
Difficulty
implementationstrings
English · Original
Chinese · Translation
Formal · Original
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "_a_", "_o_", "_u_", "_i_", and "_e_". Other letters are consonant. In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant "_n_"; after this letter, there can be any letter (not only a vowel) or there can be no letter at all. For example, the words "_harakiri_", "_yupie_", "_man_", and "_nbo_" are Berlanese while the words "_horse_", "_king_", "_my_", and "_nz_" are not. Help Vitya find out if a word $s$ is Berlanese. ## Input The first line of the input contains the string $s$ consisting of $|s|$ ($1\leq |s|\leq 100$) lowercase Latin letters. ## Output Print "_YES_" (without quotes) if there is a vowel after every consonant except "_n_", otherwise print "_NO_". You can print each letter in any case (upper or lower). [samples] ## Note In the first and second samples, a vowel goes after each consonant except "_n_", so the word is Berlanese. In the third sample, the consonant "_c_" goes after the consonant "_r_", and the consonant "_s_" stands on the end, so the word is not Berlanese.
Vitya 刚刚开始学习 Berlanese 语言。已知 Berlanese 使用拉丁字母。元音字母为 "_a_"、"_o_"、"_u_"、"_i_" 和 "_e_"。其他字母均为辅音。 在 Berlanese 中,每个辅音后必须紧跟一个元音,但元音后可以跟任意字母。唯一的例外是辅音 "_n_":在其后可以跟任意字母(不一定是元音),也可以没有字母。例如,单词 "_harakiri_"、"_yupie_"、"_man_" 和 "_nbo_" 是 Berlanese 词,而 "_horse_"、"_king_"、"_my_" 和 "_nz_" 则不是。 请帮助 Vitya 判断一个单词 $s$ 是否为 Berlanese 词。 输入的第一行包含一个字符串 $s$,由 $| s |$($1 lt.eq | s | lt.eq 100$)个小写拉丁字母组成。 如果每个辅音(除了 "_n_")后面都紧跟一个元音,则输出 "_YES_"(不带引号);否则输出 "_NO_"。 你可以以任意大小写形式输出每个字母。 在第一个和第二个样例中,每个辅音(除了 "_n_")后面都跟了一个元音,因此该词是 Berlanese 词。 在第三个样例中,辅音 "_c_" 出现在辅音 "_r_" 之后,且辅音 "_s_" 位于词尾,因此该词不是 Berlanese 词。 ## Input 输入的第一行包含一个字符串 $s$,由 $| s |$($1 lt.eq | s | lt.eq 100$)个小写拉丁字母组成。 ## Output 如果每个辅音(除了 "_n_")后面都紧跟一个元音,则输出 "_YES_"(不带引号);否则输出 "_NO_"。你可以以任意大小写形式输出每个字母。 [samples] ## Note 在第一个和第二个样例中,每个辅音(除了 "_n_")后面都跟了一个元音,因此该词是 Berlanese 词。在第三个样例中,辅音 "_c_" 出现在辅音 "_r_" 之后,且辅音 "_s_" 位于词尾,因此该词不是 Berlanese 词。
**Definitions** Let $ s = s_1 s_2 \dots s_{|s|} $ be a string of length $ |s| \in \mathbb{Z}^+ $, where each $ s_i \in \{a, b, \dots, z\} $. Let $ V = \{a, e, i, o, u\} $ be the set of vowels. Let $ C = \{b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, y, z\} $ be the set of consonants. Let $ N = \{n\} \subset C $ be the special consonant. **Constraints** $ 1 \leq |s| \leq 100 $ **Objective** Determine whether $ s $ is a Berlanese word, i.e., for every position $ i \in \{1, \dots, |s|\} $: - If $ s_i \in C \setminus N $, then either: - $ i < |s| $ and $ s_{i+1} \in V $, or - $ i = |s| $ (invalid — no vowel follows). - If $ s_i = n $, no restriction on $ s_{i+1} $. - If $ s_i \in V $, no restriction. **Output** $$ \begin{cases} \text{YES} & \text{if } \forall i \in \{1, \dots, |s|\},\ s_i \in C \setminus N \implies (i < |s| \land s_{i+1} \in V) \\ \text{NO} & \text{otherwise} \end{cases} $$
Samples
Input #1
sumimasen
Output #1
YES
Input #2
ninja
Output #2
YES
Input #3
codeforces
Output #3
NO
API Response (JSON)
{
  "problem": {
    "name": "A. Romaji",
    "description": {
      "content": "Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are \"_a_\", \"_o_\", \"_u_\", \"_i_\", and \"_e_\". Other letters are consonant. In Berlan",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF1008A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are \"_a_\", \"_o_\", \"_u_\", \"_i_\", and \"_e_\". Other letters are consonant.\n\nIn Berlan...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Vitya 刚刚开始学习 Berlanese 语言。已知 Berlanese 使用拉丁字母。元音字母为 \"_a_\"、\"_o_\"、\"_u_\"、\"_i_\" 和 \"_e_\"。其他字母均为辅音。\n\n在 Berlanese 中,每个辅音后必须紧跟一个元音,但元音后可以跟任意字母。唯一的例外是辅音 \"_n_\":在其后可以跟任意字母(不一定是元音),也可以没有字母。例如,单词 \"_harakiri_\"、\"_yu...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ s = s_1 s_2 \\dots s_{|s|} $ be a string of length $ |s| \\in \\mathbb{Z}^+ $, where each $ s_i \\in \\{a, b, \\dots, z\\} $.  \nLet $ V = \\{a, e, i, o, u\\} $ be the set of vowels.  \nL...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments