#include <algorithm> #include <iostream> #include <iterator> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); bool vowel[128]{}; for (int c : "aeiouy") { vowel[c] = true; } std::istream_iterator<char> over, in(std::cin); bool prev_bit = false; int i = -1; int counter = 0; int prev_triple = 0; long long result = 0; std::for_each(in, over, [&](int c) { bool bit = vowel[c]; if (bit == prev_bit) { counter++; if (counter >= 3) { prev_triple = i; } } else { prev_bit = bit; counter = 1; } result += prev_triple; i++; }); std::cout << result; }
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 | #include <algorithm> #include <iostream> #include <iterator> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); bool vowel[128]{}; for (int c : "aeiouy") { vowel[c] = true; } std::istream_iterator<char> over, in(std::cin); bool prev_bit = false; int i = -1; int counter = 0; int prev_triple = 0; long long result = 0; std::for_each(in, over, [&](int c) { bool bit = vowel[c]; if (bit == prev_bit) { counter++; if (counter >= 3) { prev_triple = i; } } else { prev_bit = bit; counter = 1; } result += prev_triple; i++; }); std::cout << result; } |