//Adam Furtak
#include <bits/stdc++.h>
const std::array<char, 6> vowels = {'a', 'e', 'i', 'o', 'u', 'y'};
bool is_vowel(char t) {
for (const auto &letter : vowels) {
if (t == letter)
return true;
}
return false;
}
long long solve(std::string &text) {
std::vector<bool> occurences(text.size());
long long result = 0;
int last = 1;
for (int i = 2; i < text.size(); i++) {
if ((is_vowel(text[i - 2]) && is_vowel(text[i - 1]) && is_vowel(text[i]))
|| (!is_vowel(text[i - 2]) && !is_vowel(text[i - 1]) && !is_vowel(text[i])))
{
last = i;
}
result += (last - 1);
}
return result;
}
int main() {
std::ios_base::sync_with_stdio(false);
std::string text;
std::cin >> text;
std::cout << solve(text) << std::endl;
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 | //Adam Furtak #include <bits/stdc++.h> const std::array<char, 6> vowels = {'a', 'e', 'i', 'o', 'u', 'y'}; bool is_vowel(char t) { for (const auto &letter : vowels) { if (t == letter) return true; } return false; } long long solve(std::string &text) { std::vector<bool> occurences(text.size()); long long result = 0; int last = 1; for (int i = 2; i < text.size(); i++) { if ((is_vowel(text[i - 2]) && is_vowel(text[i - 1]) && is_vowel(text[i])) || (!is_vowel(text[i - 2]) && !is_vowel(text[i - 1]) && !is_vowel(text[i]))) { last = i; } result += (last - 1); } return result; } int main() { std::ios_base::sync_with_stdio(false); std::string text; std::cin >> text; std::cout << solve(text) << std::endl; return 0; } |
English