#include <iostream> #include <vector> using namespace std; string s; bool czysam(char ch) { return ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='y'; } vector<int> pop; int popi; long long sumeks=0; int main() { ios_base::sync_with_stdio(false); cin>>s; short sam=0; for(int i = 0; i<3; i++) if(czysam(s[i])) sam++; if(sam==0||sam==3){ pop.push_back(1);popi=1;if(s.size()>=3)sumeks++;} else pop.push_back(0); //cout<<sam; for(int i = 3; i<s.size(); i++){ if(czysam(s[i])){ sam++; } if(czysam(s[i-3])){ sam--; } if(sam==0||sam==3) popi=i-1; sumeks+=popi; pop.push_back(popi); } cout<<sumeks<<"\n"; /*(for(int i = 0; i<pop.size(); i++){ cout<<pop[i]<<" "; }*/ 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <iostream> #include <vector> using namespace std; string s; bool czysam(char ch) { return ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='y'; } vector<int> pop; int popi; long long sumeks=0; int main() { ios_base::sync_with_stdio(false); cin>>s; short sam=0; for(int i = 0; i<3; i++) if(czysam(s[i])) sam++; if(sam==0||sam==3){ pop.push_back(1);popi=1;if(s.size()>=3)sumeks++;} else pop.push_back(0); //cout<<sam; for(int i = 3; i<s.size(); i++){ if(czysam(s[i])){ sam++; } if(czysam(s[i-3])){ sam--; } if(sam==0||sam==3) popi=i-1; sumeks+=popi; pop.push_back(popi); } cout<<sumeks<<"\n"; /*(for(int i = 0; i<pop.size(); i++){ cout<<pop[i]<<" "; }*/ return 0; } |