#include <cstdio> #include <cstring> #include <iostream> using namespace std; #define MAX 201000 #define I long long #define D(x) char in[MAX]; char sa[500]; char sam[] = "aeiouy"; int main() { I s, ile = 0, pos = -1,sum=0; scanf("%s",in); s = strlen(in); for(I i=0;sam[i];i++) sa[sam[i]]=1; char sp = 0; for(I i=0;i<s;i++) { if(sp == sa[in[i]]) { ile++; } else { sp = sa[in[i]]; ile=1; } if(ile>2) { pos = i-2; } sum+=(i-pos); D(cout << i << " " << ile << " " << pos << " sum:" << i-pos << "\n"); } cout << s*(s+1)/2 - sum << "\n"; }
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 | #include <cstdio> #include <cstring> #include <iostream> using namespace std; #define MAX 201000 #define I long long #define D(x) char in[MAX]; char sa[500]; char sam[] = "aeiouy"; int main() { I s, ile = 0, pos = -1,sum=0; scanf("%s",in); s = strlen(in); for(I i=0;sam[i];i++) sa[sam[i]]=1; char sp = 0; for(I i=0;i<s;i++) { if(sp == sa[in[i]]) { ile++; } else { sp = sa[in[i]]; ile=1; } if(ile>2) { pos = i-2; } sum+=(i-pos); D(cout << i << " " << ile << " " << pos << " sum:" << i-pos << "\n"); } cout << s*(s+1)/2 - sum << "\n"; } |