#include<cstdio> #include<cstring> #define maxn 300000 using namespace std; char s[maxn]; int k[maxn],kon; long long wyn,n; bool typ[300]; int main() { typ['a']=1;typ['e']=1; typ['i']=1;typ['o']=1; typ['u']=1;typ['y']=1; scanf("%s",s); n=strlen(s); kon=n; k[n-1]=k[n-2]=kon; for(int i=n-3;i>=0;i--) { if(typ[s[i]]==typ[s[i+1]]&&typ[s[i+1]]==typ[s[i+2]])kon=i+2; k[i]=kon; } wyn=n*(n+1)/2; for(int i=0;i<=n-1;i++)wyn-=k[i]-i; printf("%lld",wyn); }
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 | #include<cstdio> #include<cstring> #define maxn 300000 using namespace std; char s[maxn]; int k[maxn],kon; long long wyn,n; bool typ[300]; int main() { typ['a']=1;typ['e']=1; typ['i']=1;typ['o']=1; typ['u']=1;typ['y']=1; scanf("%s",s); n=strlen(s); kon=n; k[n-1]=k[n-2]=kon; for(int i=n-3;i>=0;i--) { if(typ[s[i]]==typ[s[i+1]]&&typ[s[i+1]]==typ[s[i+2]])kon=i+2; k[i]=kon; } wyn=n*(n+1)/2; for(int i=0;i<=n-1;i++)wyn-=k[i]-i; printf("%lld",wyn); } |