#include<bits/stdc++.h> using namespace std; string s; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long xd=0; int a=0,n; cin>>s; n=s.length(); s+='#'; for(int i=0; i<n; i++){ if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='y') s[i]=1; else s[i]=0; } for(int i=0; i<n; i++){ if(a-i<2) a=i+2; while(a<n&&(s[a]!=s[a-1]||s[a]!=s[a-2])) a++; if(a>=n) break; xd+=n-a; } cout<<xd<<'\n'; 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 | #include<bits/stdc++.h> using namespace std; string s; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long xd=0; int a=0,n; cin>>s; n=s.length(); s+='#'; for(int i=0; i<n; i++){ if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='y') s[i]=1; else s[i]=0; } for(int i=0; i<n; i++){ if(a-i<2) a=i+2; while(a<n&&(s[a]!=s[a-1]||s[a]!=s[a-2])) a++; if(a>=n) break; xd+=n-a; } cout<<xd<<'\n'; return 0; } |