#include<bits/stdc++.h> #define VAR(i,n) __typeof(n) i = (n) #define loop(i,j,s) for(int i=j;i<s;i++) #define loopback(i,j,s) for(int i=j;i>=s;i--) #define foreach(i,c) for(VAR(i,(c).begin());i!=(c).end();i++) #define pln( x ) cout << x << "\n" #define ps( x ) cout << x << " " #define entr cout << "\n" #define pcnt(i) __builtin_popcount(i) #define ll long long #define pb push_back #define mp make_pair #define ff first #define ss second #define SIZE(c) (c).size() #define ALL(c) (c).begin(), (c).end() using namespace std; typedef vector<int> VI; const int INFTY=20000000; const int MAX=200100; const int MOD=10000000; void coutTab(bool* tab,int n){ loop(i,0,n){ cout<<tab[i]<<" "; } cout<<"\n"; } //------------------------------------------ bool isVowel[MAX]; bool isEnd[MAX]; int near[MAX]; void countVowels(){ string vovels = "aeiouy"; for(char s:vovels) isVowel[s-'a']=true; } bool isVow(char a){ return isVowel[a-'a']; } bool exact(string & s, int i){ return (isVow(s[i-2])==isVow(s[i-1]))&&(isVow(s[i-1])==isVow(s[i])); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); countVowels(); string s; cin>>s; if(s.size()<3){ pln(0); return 0; } int n = s.size(); loop(i,2,n){ if(exact(s,i)) isEnd[i]=true; } near[n-1]=-1; near[n-2]=-1; near[n-3]=exact(s,n-1) ? n-1 : -1; loopback(i,n-4,0){ if(isEnd[i+2]) near[i]=i+2; else near[i]=near[i+1]; } ll res=0; loop(i,0,n){ if(near[i]!=-1) res = res + n - near[i]; } pln(res); }
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include<bits/stdc++.h> #define VAR(i,n) __typeof(n) i = (n) #define loop(i,j,s) for(int i=j;i<s;i++) #define loopback(i,j,s) for(int i=j;i>=s;i--) #define foreach(i,c) for(VAR(i,(c).begin());i!=(c).end();i++) #define pln( x ) cout << x << "\n" #define ps( x ) cout << x << " " #define entr cout << "\n" #define pcnt(i) __builtin_popcount(i) #define ll long long #define pb push_back #define mp make_pair #define ff first #define ss second #define SIZE(c) (c).size() #define ALL(c) (c).begin(), (c).end() using namespace std; typedef vector<int> VI; const int INFTY=20000000; const int MAX=200100; const int MOD=10000000; void coutTab(bool* tab,int n){ loop(i,0,n){ cout<<tab[i]<<" "; } cout<<"\n"; } //------------------------------------------ bool isVowel[MAX]; bool isEnd[MAX]; int near[MAX]; void countVowels(){ string vovels = "aeiouy"; for(char s:vovels) isVowel[s-'a']=true; } bool isVow(char a){ return isVowel[a-'a']; } bool exact(string & s, int i){ return (isVow(s[i-2])==isVow(s[i-1]))&&(isVow(s[i-1])==isVow(s[i])); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); countVowels(); string s; cin>>s; if(s.size()<3){ pln(0); return 0; } int n = s.size(); loop(i,2,n){ if(exact(s,i)) isEnd[i]=true; } near[n-1]=-1; near[n-2]=-1; near[n-3]=exact(s,n-1) ? n-1 : -1; loopback(i,n-4,0){ if(isEnd[i+2]) near[i]=i+2; else near[i]=near[i+1]; } ll res=0; loop(i,0,n){ if(near[i]!=-1) res = res + n - near[i]; } pln(res); } |