1008A Romaji

A. Romaji
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ss is Berlanese.

Input

The first line of the input contains the string ss consisting of |s||s| (1|s|1001≤|s|≤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).

Examples
input
Copy
sumimasen
output
Copy
YES
input
Copy
ninja
output
Copy
YES
input
Copy
codeforces
output
Copy
NO
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.


题意:输入一串字符,判断每一位辅音字母后面是否都有一位元音字母,n是例外的。如果满足每位辅音字母都有元音,就输出YES,否则就输出NO

题解:模拟  

c++:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string  s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
        if(strchr("aeioun",s[i])==NULL and strchr("aeiou",s[i+1])==NULL or strchr("aeioun",s[s.size()-1])==NULL)
        {
            printf("NO");
            return 0;
        }
    printf("YES");
    return 0;
}

python:

s=input()
a="aeiou"
for i in s:
    if i not in a and i!="n":
        if s[-1] not in "aeioun"or s[s.index(i)+1] not in a:
            print("NO")
            exit()
print("YES")


猜你喜欢

转载自blog.csdn.net/memory_qianxiao/article/details/81040407