Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss576 - | Accepted | C++11 | 0.000 | 0.000 | 1738 | 7 mins ago |
Suggest:
This can be solved through two simple steps:
- Firstly, we remove consecutive vowels.
- Next, we count the vowels in the string to compare with 5/7/5.
#include <bits/stdc++.h>
using namespace std;
bool isVowel(char c) {
char vowels[] = {'a', 'e', 'i', 'o', 'u', 'y'};
for (char vowel : vowels) {
if (c == vowel) {
return true;
}
}
return false;
}
string fdel(string s) {
for (int i = 0; s[i+1]; i++)
if (isVowel(s[i]) && isVowel(s[i + 1])) {
s.erase(i, 1);
i--;
}
return s;
}
int fcnt(string s){
int cnt= 0;
for (int i = 0; s[i]; i++)
if (isVowel(s[i])) cnt++;
return cnt;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
string s, a, b, c;
while (true) {
getline(cin, s);
a="", b="", c="";
int i;
for(i=0; s[i]; i++){
if (s[i]=='/') break;
a+=s[i];
}
for(i=i+1; s[i]; i++){
if (s[i]=='/') break;
b+=s[i];
}
for(i=i+1; s[i]; i++){
if (s[i]=='/') break;
c+=s[i];
}
if (a == "e" && b == "o" && c == "i") break;
if (fcnt(fdel(a)) != 5) cout<<1;
else if (fcnt(fdel(b)) != 7) cout<<2;
else if (fcnt(fdel(c)) != 5) cout<<3;
else cout<<"Y";
cout<<"\n";
}
}
No comments:
Post a Comment