#include <iostream> #include <string> inline int isVowel(char c) { return int(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); long long result = 0ll; std::string s; std::cin >> s; int stringSize = s.size(); int lastPos = -1, currPos = stringSize - 1; while (currPos--) { if (currPos + 2 >= stringSize) { continue; } int chars = isVowel(s[currPos]) + isVowel(s[currPos + 1]) + isVowel(s[currPos + 2]); if (chars == 3 || chars == 0) { lastPos = currPos; } if (lastPos == -1) { continue; } result += (stringSize - lastPos - 2); } std::cout << result; 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 | #include <iostream> #include <string> inline int isVowel(char c) { return int(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); long long result = 0ll; std::string s; std::cin >> s; int stringSize = s.size(); int lastPos = -1, currPos = stringSize - 1; while (currPos--) { if (currPos + 2 >= stringSize) { continue; } int chars = isVowel(s[currPos]) + isVowel(s[currPos + 1]) + isVowel(s[currPos + 2]); if (chars == 3 || chars == 0) { lastPos = currPos; } if (lastPos == -1) { continue; } result += (stringSize - lastPos - 2); } std::cout << result; return 0; } |