#include<bits/stdc++.h> using namespace std; using i64=long long; const int N=2e5+5; int n,v[N];char s[N];i64 g; int main(){ int i,j; scanf("%s",s+1),n=strlen(s+1); for(i=1;i<=n;i++)for(char c:string("aeiouy"))v[i]+=s[i]==c; for(i=3,j=1;i<=n;i++){ if(v[i-2]==v[i-1]&&v[i-1]==v[i])j=i-1; g+=j-1; } printf("%lld\n",g); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<bits/stdc++.h> using namespace std; using i64=long long; const int N=2e5+5; int n,v[N];char s[N];i64 g; int main(){ int i,j; scanf("%s",s+1),n=strlen(s+1); for(i=1;i<=n;i++)for(char c:string("aeiouy"))v[i]+=s[i]==c; for(i=3,j=1;i<=n;i++){ if(v[i-2]==v[i-1]&&v[i-1]==v[i])j=i-1; g+=j-1; } printf("%lld\n",g); } |