#include <cstdint> #include <cstdio> #include <cstring> using namespace std; #define isVowel(_arg) (_arg == 'a' || _arg == 'e' || _arg == 'i' || _arg == 'o' || _arg == 'u' || _arg == 'y') const int32_t maxlen = 200000; const int8_t th = 3; // threshold int main() { int32_t i, n, from, seg; int8_t curr, prev, same; int64_t count; char tab[maxlen + 1]; scanf("%s", tab); n = strlen(tab); count = 0, from = 0; prev = 2; same = 1; for (i = 0; i < n; ++i) { curr = isVowel(tab[i]); if (curr == prev) { if (same < th) { ++same; } } else { prev = curr; same = 1; } if (same == th) { seg = i - 2; count += (seg - from + 1) * (n - i); from = seg + 1; } } printf("%lld", count); return 0; }
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 39 40 41 42 43 | #include <cstdint> #include <cstdio> #include <cstring> using namespace std; #define isVowel(_arg) (_arg == 'a' || _arg == 'e' || _arg == 'i' || _arg == 'o' || _arg == 'u' || _arg == 'y') const int32_t maxlen = 200000; const int8_t th = 3; // threshold int main() { int32_t i, n, from, seg; int8_t curr, prev, same; int64_t count; char tab[maxlen + 1]; scanf("%s", tab); n = strlen(tab); count = 0, from = 0; prev = 2; same = 1; for (i = 0; i < n; ++i) { curr = isVowel(tab[i]); if (curr == prev) { if (same < th) { ++same; } } else { prev = curr; same = 1; } if (same == th) { seg = i - 2; count += (seg - from + 1) * (n - i); from = seg + 1; } } printf("%lld", count); return 0; } |