#include <bits/stdc++.h> #define deb(x) #define fr front #define pob pop_back #define last(V) V[V.size()-1] #define sp <<" "<< #define ent <<"\n" #define mp make_pair #define pb push_back #define pu push #define st first #define nd second #define VI vector<int> #define VII vector<pair<int,int> > #define inf 1000000009 #define uns unsigned #define ll long long #define ld long double #define uint unsigned int using namespace std; const int MN=0; bool t[200010]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string n; cin>>n; int ns = n.size(); for(int i=0;i<ns;i++) { if(n[i]=='a' ||n[i]=='e' ||n[i]=='i' ||n[i]=='o' ||n[i]=='u' ||n[i]=='y') t[i]=1; else t[i]=0; } /* for(int i=0;i<ns;i++) cout<<t[i]; cout ent; */ ll odp=0,l=0; bool ok=0; for(int i=2;i<ns;i++) { if((t[i]+t[i-1]+t[i-2])%3==0) { ok=1; l=i-2; } if(ok) { odp+=l+1; } // cout<<odp sp n[i-2] sp n[i-1] sp n[i] ent; } cout<<odp ent; 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 49 50 51 52 53 54 55 56 57 58 | #include <bits/stdc++.h> #define deb(x) #define fr front #define pob pop_back #define last(V) V[V.size()-1] #define sp <<" "<< #define ent <<"\n" #define mp make_pair #define pb push_back #define pu push #define st first #define nd second #define VI vector<int> #define VII vector<pair<int,int> > #define inf 1000000009 #define uns unsigned #define ll long long #define ld long double #define uint unsigned int using namespace std; const int MN=0; bool t[200010]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string n; cin>>n; int ns = n.size(); for(int i=0;i<ns;i++) { if(n[i]=='a' ||n[i]=='e' ||n[i]=='i' ||n[i]=='o' ||n[i]=='u' ||n[i]=='y') t[i]=1; else t[i]=0; } /* for(int i=0;i<ns;i++) cout<<t[i]; cout ent; */ ll odp=0,l=0; bool ok=0; for(int i=2;i<ns;i++) { if((t[i]+t[i-1]+t[i-2])%3==0) { ok=1; l=i-2; } if(ok) { odp+=l+1; } // cout<<odp sp n[i-2] sp n[i-1] sp n[i] ent; } cout<<odp ent; return 0; } |