#include <cstdio> #include <cstring> char s[200001]; bool vowel[256]; int main() { vowel['a'] = true; vowel['e'] = true; vowel['i'] = true; vowel['o'] = true; vowel['u'] = true; vowel['y'] = true; scanf("%s", s); int n = strlen(s); int mask = 0; int cnt = 0; long long ans = (long long) (n-2) * (n-1) / 2; if(vowel[s[0]]) mask |= 0x1; if(vowel[s[1]]) mask |= 0x2; for(char* i = s+2; *i; ++i) { if(vowel[*i]) mask |= 0x4; if(mask == 0 || mask == 0x7) cnt = 0; else cnt++; ans -= cnt; mask >>= 1; } printf("%lli", ans); }
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 35 36 37 38 | #include <cstdio> #include <cstring> char s[200001]; bool vowel[256]; int main() { vowel['a'] = true; vowel['e'] = true; vowel['i'] = true; vowel['o'] = true; vowel['u'] = true; vowel['y'] = true; scanf("%s", s); int n = strlen(s); int mask = 0; int cnt = 0; long long ans = (long long) (n-2) * (n-1) / 2; if(vowel[s[0]]) mask |= 0x1; if(vowel[s[1]]) mask |= 0x2; for(char* i = s+2; *i; ++i) { if(vowel[*i]) mask |= 0x4; if(mask == 0 || mask == 0x7) cnt = 0; else cnt++; ans -= cnt; mask >>= 1; } printf("%lli", ans); } |