Romaji
题目描述
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 s s is Berlanese.
输入格式
The first line of the input contains the string s s s consisting of ∣ s ∣ |s| ∣s∣ ( 1 ≤ ∣ s ∣ ≤ 100 1\leq |s|\leq 100 1≤∣s∣≤100 ) lowercase Latin letters.
输出格式
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).
题面翻译
伯兰语有五个元音字母,分别是 a
,e
,i
,o
,u
。伯兰语单词中的每一个非元音(除了 n
)后都是元音或 n
(没有字母也不行,即单词末尾必须是这六个字符之一)。而元音和 n
没有此限制。
如 harakiri
,yupie
,man
和 nbo
都是符合规范的,而 horse
,king
,my
,nz
都不符合。给你一个单词,问是否符合伯兰语单词的规范。
输入仅一行,是你需要判断是否符合规范的单词。
输出仅一行,若符合则输出 YES
,否则输出 NO
。
样例解释3:字母 r
后是 c
,不属于元音或 n
且单词末尾是 s
,不符合要求,故输出 NO
。
样例 #1
样例输入 #1
sumimasen
样例输出 #1
YES
样例 #2
样例输入 #2
ninja
样例输出 #2
YES
样例 #3
样例输入 #3
codeforces
样例输出 #3
NO
提示
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.
思路
按照题意模拟即可
/*************************************************
Note:
*************************************************/
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#define ll long long
#define ull unsigned long long
using namespace std;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
inline int read()
{
int s = 0, w = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
s = s * 10 + ch - '0', ch = getchar();
return s * w;
}
string s1;
bool check(char x)
{
return x != 'a' && x != 'e' && x != 'i' && x != 'o' && x != 'u';
}
int main()
{
cin >> s1;
int len = s1.length();
for (int i = 0; i < len; i++)
{
if (check(s1[i]) && check(s1[i + 1]) && s1[i] != 'n')
{
puts("NO");
exit(0);
}
}
puts("YES");
return 0;
}