#include <bits/stdc++.h> #define lld long long using namespace std; bitset<256> g; char s[200009]; int n,k; bitset<200009> d; lld suma; int main() { g['a']=1; g['e']=1; g['i']=1; g['u']=1; g['y']=1; g['o']=1; scanf("%s",&s); while(s[n]) { d[n]=g[s[n]]; ++n; } k=2; for(int i=0;i<n;++i) { while(((d[k]!=d[k-1]||d[k]!=d[k-2])||(i+2>k))&&(k<n)) k++; if(k<n&&i+1<k)suma=suma+n-k; } printf("%lld",suma); 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 | #include <bits/stdc++.h> #define lld long long using namespace std; bitset<256> g; char s[200009]; int n,k; bitset<200009> d; lld suma; int main() { g['a']=1; g['e']=1; g['i']=1; g['u']=1; g['y']=1; g['o']=1; scanf("%s",&s); while(s[n]) { d[n]=g[s[n]]; ++n; } k=2; for(int i=0;i<n;++i) { while(((d[k]!=d[k-1]||d[k]!=d[k-2])||(i+2>k))&&(k<n)) k++; if(k<n&&i+1<k)suma=suma+n-k; } printf("%lld",suma); return 0; } |