#include <cstdio> #include <cstdint> using namespace std; char T[200001]; char oddVals[] = {'a', 'e', 'i', 'o', 'u', 'y'}; bool TT['z' + 1]; bool isOdd(int v) { return TT[v]; } int main() { scanf("%s", T); uint64_t sum = 0, last = 0; for (int v: oddVals) { TT[v] = true; } int odd = 0; int even = 0; for (int i = 0; T[i]; ++i) { if (isOdd(T[i])) { ++odd; even = 0; } else { ++even; odd = 0; } if (even >= 3 || odd >= 3) { last = (i-2) + 1; } sum += last; } printf("%lld\n", sum); 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 44 45 46 | #include <cstdio> #include <cstdint> using namespace std; char T[200001]; char oddVals[] = {'a', 'e', 'i', 'o', 'u', 'y'}; bool TT['z' + 1]; bool isOdd(int v) { return TT[v]; } int main() { scanf("%s", T); uint64_t sum = 0, last = 0; for (int v: oddVals) { TT[v] = true; } int odd = 0; int even = 0; for (int i = 0; T[i]; ++i) { if (isOdd(T[i])) { ++odd; even = 0; } else { ++even; odd = 0; } if (even >= 3 || odd >= 3) { last = (i-2) + 1; } sum += last; } printf("%lld\n", sum); return 0; } |