Romaji (CodeForces - 1008A )
Posted baiyi-destroyer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
sumimasen
YES
ninja
YES
codeforces
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 ",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 }
以上是关于Romaji (CodeForces - 1008A )的主要内容,如果未能解决你的问题,请参考以下文章
使 UITextfield 只接受片假名字符 - swift