#include <iostream> #include <string> #include <vector> #include <cstdint> int main() { std::string tmp; std::cin >> tmp; const size_t n = tmp.size(); auto is_safe = [&](size_t i) -> bool { return !((i >= 3 && tmp[i - 3] == tmp[i - 1] && tmp[i - 2] == tmp[i - 1])); }; for(auto &q : tmp) q = (q == 'a' || q == 'e' || q == 'i' || q== 'o' || q == 'u' || q == 'y') ? '1' : '0'; std::uint64_t unsafe = 0; size_t i = 0; while(i < n) { auto k = i + 3; for(; k <= n && is_safe(k); ++k) { } if (k > n) break; unsafe += (n - k + 1) * (k - i - 2); i = k - 2; } std::cout << unsafe; 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 | #include <iostream> #include <string> #include <vector> #include <cstdint> int main() { std::string tmp; std::cin >> tmp; const size_t n = tmp.size(); auto is_safe = [&](size_t i) -> bool { return !((i >= 3 && tmp[i - 3] == tmp[i - 1] && tmp[i - 2] == tmp[i - 1])); }; for(auto &q : tmp) q = (q == 'a' || q == 'e' || q == 'i' || q== 'o' || q == 'u' || q == 'y') ? '1' : '0'; std::uint64_t unsafe = 0; size_t i = 0; while(i < n) { auto k = i + 3; for(; k <= n && is_safe(k); ++k) { } if (k > n) break; unsafe += (n - k + 1) * (k - i - 2); i = k - 2; } std::cout << unsafe; return 0; } |