Romaji (CodeForces - 1008A )

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

sumimasen

Output

YES

Input

ninja

Output

YES

Input

codeforces

Output

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.

题解:大水题,可惜没看清题意wa了好多发,注意辅音后面紧跟元音如果跟n是输出NO的。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<cstring>
 5 #include<string>
 6 #include<cmath>
 7 #include<map>
 8 #include<stack>
 9 #include<vector>
10 #include<queue>
11 #include<set>
12 #include<algorithm>
13 #define max(a,b)   (a>b?a:b)
14 #define min(a,b)   (a<b?a:b)
15 #define swap(a,b)  (a=a+b,b=a-b,a=a-b)
16 #define maxn 320007
17 #define N 100000000
18 #define INF 0x3f3f3f3f
19 #define mod 1000000009
20 #define e  2.718281828459045
21 #define eps 1.0e18
22 #define PI acos(-1)
23 #define lowbit(x) (x&(-x))
24 #define read(x) scanf("%d",&x)
25 #define put(x) printf("%d\n",x)
26 #define memset(x,y) memset(x,y,sizeof(x))
27 #define Debug(x) cout<<x<<" "<<endl
28 #define lson i << 1,l,m
29 #define rson i << 1 | 1,m + 1,r
30 #define ll long long
31 //std::ios::sync_with_stdio(false);
32 //cin.tie(NULL);
33 using namespace std;
34
35 char a[111];
36 int b[111];
37 int main()
38 {
39     cin>>a;
40     int l=strlen(a);
41     for(int i=0;i<l;i++)
42     {
43         if(a[i]!=‘a‘&&a[i]!=‘e‘&&a[i]!=‘i‘&&a[i]!=‘o‘&&a[i]!=‘u‘)
44             b[a[i]-‘a‘]++;
45     }
46
47     int i,flag=0;
48     for(i=0;i<l-1;i++)
49     {
50         if(b[a[i]-‘a‘]&&a[i]!=‘n‘&&b[a[i+1]-‘a‘])
51         {
52             flag=1;
53             //cout<<i<<endl;
54         }
55     }
56     if(!flag&&(!b[a[l-1]-‘a‘]||a[i]==‘n‘))
57         cout<<"YES"<<endl;
58     else
59         cout<<"NO"<<endl;
60     return 0;
61 }

原文地址:https://www.cnblogs.com/baiyi-destroyer/p/9734957.html

时间: 2024-10-19 10:22:44

Romaji (CodeForces - 1008A )的相关文章

[题解]Yet Another Subarray Problem-DP 、思维(codeforces 1197D)

题目链接:https://codeforces.com/problemset/problem/1197/D 题意: 给你一个序列,求一个子序列 a[l]~a[r] 使得该子序列的 sum(l,r)-k*(r-l+1)/m(向上取整)的值是在所有子序列中最大的,并输出最大值 思路: 法一:动态规划 dp[i][j] 表示序列到i截止,这一轮已经进行了j次取数(j = (len+m-1)%m) 那么dp[i][j]维护的就是起点为 s = i-j+1-m*t (t>=0)这个集合的最优,这样所有的

AC自动机+dp(CodeForces - 86C )

"Multidimensional spaces are completely out of style these days, unlike genetics problems" — thought physicist Woll and changed his subject of study to bioinformatics. Analysing results of sequencing he faced the following problem concerning DNA

Palindrome Degree(CodeForces 7D)—— hash求回文

学了kmp之后又学了hash来搞字符串.这东西很巧妙,且听娓娓道来. 这题的题意是:一个字符串如果是回文的,那么k值加1,如果前一半的串也是回文,k值再加1,以此类推,算出其k值.打个比方abaaba,k值为3,abaxxaba,k值为1.现在,给出一个串,让你求这个串的所有前缀(包括本身)的k值的和. 如果考虑马拉车,那么先预处理出每个地方的最长回文长度,然后不断的截断,如果子串的回文长度大于其回文长度,那么k值加1,这样即可.但是马拉车写起来比较繁琐,没有模板我也没法手写. 这里提供hash

A - Playing with Paper (CodeForces - 527A)

- 题目大意 给定的矩形,每次裁剪最大的正方形,直到最后剩下正方形,总共有多少个正方形. - 解题思路 显然,每次裁剪后,原来的宽和(长-宽)变成了现在的长和宽,直到长等于宽. - 代码 #include<iostream> using namespace std; long long num(long long a, long long b) { if (b == 1) return a; if (a % b == 0) return a / b; return num(b, a % b)

「6月雅礼集训 2017 Day10」perm(CodeForces 698F)

[题目大意] 给出一个$n$个数的序列$\{a_n\}$,其中有些地方的数为0,要求你把这个序列填成一个1到$n$的排列,使得: $(a_i, a_j) = 1$,当且仅当$(i, j) = 1$.多组数据. $n \leq 3\times 10^5, T\leq 10$ CodeForces:无多组数据,$n \leq 10^6$ [题解] 这题有点神奇啊.. 首先考虑序列全是0要怎么做. 考虑到如果两个数的位置含有的因数种类完全一样,那么它们是可以互换的.(这个挺显然的) 观察如果两个质数的

[题解]Print a 1337-string...-数学(codeforces 1202D)

题目链接:https://codeforces.com/problemset/problem/1202/D 题意: 构造一串只由 ‘1’,‘3’,‘7’ 组成的字符串,使其 ‘1337’ 子序列数量为n 思路: 构造 ‘13377733337’ 类型的字符串,使 C(2,m)+k=n k为中间 ‘7’ 的数量,C(2,m)为中间 ‘3’ 的数量 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4

Fence(codeforces 232D)

题意: 对于给定的a[1..n],定义区间[s,t]和[x,y]"匹配"当且仅当下列条件同时满足:1. t-s=y-x,即长度相同.3. t<x或s>y,即两区间没有交.2. 对任0<=i<=t-s,有a[s]+a[x]=a[s+i]+a[x+i].现给出a[1..n]和Q个询问(x,y),求与[x,y]匹配的区间的个数. /* 写了n个小时,还没有调出来,Orz... 代码量倒是不大,但是细节巨多,已经弃疗了... 先差分一下, 然后题目就变成了,也就是这段区

(CodeForces 510C) Fox And Names 拓扑排序

题目链接:http://codeforces.com/problemset/problem/510/C Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.

Playing with String(codeforces 305E)

题意:刚开始你只有一个字符串每次能选择一个有的字符串 s,找到 i,满足s[i - 1] = s[i + 1],将其分裂成 3 个字符串s[1 · · · i - 1]; s[i]; s[i + 1 · · · len]不能操作者负,求先手必胜的一个策略初始字符串长度不超过 5000 /* 一个很暴力的转移方法设SG[i][j],每次枚举断点,但是这样是O(n^3)的. 其实我们可以发现,只有一段连续的符合s[i-1]=s[i+1]的字符串才能有贡献,所以可以设SG[len]来进行转移. */