CF1008A Romaji

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

题面翻译

伯兰语有五个元音字母,分别是 aeiou。伯兰语单词中的每一个非元音(除了 n)后都是元音或 n(没有字母也不行,即单词末尾必须是这六个字符之一)。而元音和 n 没有此限制。

harakiriyupiemannbo 都是符合规范的,而 horsekingmynz 都不符合。给你一个单词,问是否符合伯兰语单词的规范。

输入仅一行,是你需要判断是否符合规范的单词。

输出仅一行,若符合则输出 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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

꧁Q༒ོγ꧂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值