#include<cstdio> int main() { char t[200005]; int i,x=0,y=0,l=-1; long long s=0; scanf("%s",t); for(i=0;t[i];++i) { if(t[i]=='a'||t[i]=='e'||t[i]=='i'||t[i]=='o'||t[i]=='u'||t[i]=='y') ++y,x=0; else ++x,y=0; if(x>2||y>2) l=i-2; s+=i-l; } printf("%lld",(long long)(i)*(i+1)/2-s); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include<cstdio> int main() { char t[200005]; int i,x=0,y=0,l=-1; long long s=0; scanf("%s",t); for(i=0;t[i];++i) { if(t[i]=='a'||t[i]=='e'||t[i]=='i'||t[i]=='o'||t[i]=='u'||t[i]=='y') ++y,x=0; else ++x,y=0; if(x>2||y>2) l=i-2; s+=i-l; } printf("%lld",(long long)(i)*(i+1)/2-s); } |