#include <bits/stdc++.h> std::string A; int lg; int i; int stop=0; int Triplet[200001]; int Sequence[200001]; long long wynik; int main() { std::cin>>A; for (i=0; i<A.size(); ++i) { if (A[i]=='a') Sequence[i]=1; if (A[i]=='e') Sequence[i]=1; if (A[i]=='i') Sequence[i]=1; if (A[i]=='o') Sequence[i]=1; if (A[i]=='u') Sequence[i]=1; if (A[i]=='y') Sequence[i]=1; } for (i=2; i<A.size(); ++i) if (((Sequence[i]==1)&&(Sequence[i-1]==1)&&(Sequence[i-2]==1))||((Sequence[i]==0)&&(Sequence[i-1]==0)&&(Sequence[i-2]==0))) Triplet[i]=1; for (i=2; i<A.size(); ++i) if (Triplet[i]==1) { wynik+=(A.size()-i)*(i-1-stop); stop=i-1; } std::cout<<wynik; 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 43 44 45 46 | #include <bits/stdc++.h> std::string A; int lg; int i; int stop=0; int Triplet[200001]; int Sequence[200001]; long long wynik; int main() { std::cin>>A; for (i=0; i<A.size(); ++i) { if (A[i]=='a') Sequence[i]=1; if (A[i]=='e') Sequence[i]=1; if (A[i]=='i') Sequence[i]=1; if (A[i]=='o') Sequence[i]=1; if (A[i]=='u') Sequence[i]=1; if (A[i]=='y') Sequence[i]=1; } for (i=2; i<A.size(); ++i) if (((Sequence[i]==1)&&(Sequence[i-1]==1)&&(Sequence[i-2]==1))||((Sequence[i]==0)&&(Sequence[i-1]==0)&&(Sequence[i-2]==0))) Triplet[i]=1; for (i=2; i<A.size(); ++i) if (Triplet[i]==1) { wynik+=(A.size()-i)*(i-1-stop); stop=i-1; } std::cout<<wynik; return 0; } |