#include<cstdio> #include<vector> #include<cstring> using namespace std; bool isVowel(char c) { return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c=='y'); } int main() { char s[200000]; vector<int> pos; pos.push_back(0); scanf("%s",s); long long result=0; int len=strlen(s); for(int i=0; i<len-2; ++i) { if((isVowel(s[i]) && isVowel(s[i+1]) && isVowel(s[i+2])) || (!isVowel(s[i]) && !isVowel(s[i+1]) && !isVowel(s[i+2])) ) pos.push_back(i+1); } for(int i =1; i< pos.size(); ++i) { result+=(pos[i]-pos[i-1])*(len-pos[i]-1); } printf("%lld\n",result); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include<cstdio> #include<vector> #include<cstring> using namespace std; bool isVowel(char c) { return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c=='y'); } int main() { char s[200000]; vector<int> pos; pos.push_back(0); scanf("%s",s); long long result=0; int len=strlen(s); for(int i=0; i<len-2; ++i) { if((isVowel(s[i]) && isVowel(s[i+1]) && isVowel(s[i+2])) || (!isVowel(s[i]) && !isVowel(s[i+1]) && !isVowel(s[i+2])) ) pos.push_back(i+1); } for(int i =1; i< pos.size(); ++i) { result+=(pos[i]-pos[i-1])*(len-pos[i]-1); } printf("%lld\n",result); return 0; } |