#include<bits/stdc++.h> using namespace std; long long int w,i,c,s,l; char s1[2000007]; bitset <2000007> B; vector <long long int> v; int main() { B.reset(); scanf("%s", s1); l=strlen(s1); for(i=0; i<l; i++) { if(s1[i] == 'a' || s1[i] == 'e' || s1[i] == 'i' || s1[i] == 'o' || s1[i] == 'u' || s1[i] == 'y') { B[i]=true; // printf("1"); } else { // printf("0"); } } c=B[0]+B[1]+B[2]; if(c == 3 || c == 0) { v.push_back(2); } for(i=3; i<l; i++) { // printf("c=%lld;\n", c); c+=B[i]; c-=B[i-3]; if(c == 0 || c == 3) { v.push_back(i); } } s=v.size(); v.push_back(l); for(i=0; i<s; i++) { w+=(v[i+1]-v[i])*(v[i]-1); } printf("%lld", w); 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 47 48 | #include<bits/stdc++.h> using namespace std; long long int w,i,c,s,l; char s1[2000007]; bitset <2000007> B; vector <long long int> v; int main() { B.reset(); scanf("%s", s1); l=strlen(s1); for(i=0; i<l; i++) { if(s1[i] == 'a' || s1[i] == 'e' || s1[i] == 'i' || s1[i] == 'o' || s1[i] == 'u' || s1[i] == 'y') { B[i]=true; // printf("1"); } else { // printf("0"); } } c=B[0]+B[1]+B[2]; if(c == 3 || c == 0) { v.push_back(2); } for(i=3; i<l; i++) { // printf("c=%lld;\n", c); c+=B[i]; c-=B[i-3]; if(c == 0 || c == 3) { v.push_back(i); } } s=v.size(); v.push_back(l); for(i=0; i<s; i++) { w+=(v[i+1]-v[i])*(v[i]-1); } printf("%lld", w); return 0; } |