#include <bits/stdc++.h> using namespace std; vector <char> vowels = { 'a', 'e', 'i', 'o', 'u', 'y' }; bool isVowel(char c) { return find(vowels.begin(), vowels.end(), c) != vowels.end(); } int main() { ios_base::sync_with_stdio(0); string s; cin >> s; int n = s.size(); vector <bool> seq(n); for (int i = 0; i < n; i++) { seq[i] = isVowel(s[i]); } int lastHard = -1; long long ans = 0; for (int i = 0; i < n; i++) { int sum = 0; if (i >= 2) { for (int j = i - 2; j <= i; j++) { sum += seq[j]; } if (sum == 0 || sum == 3) { lastHard = i - 2; } } ans += lastHard + 1; } cout << ans; 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 47 48 49 | #include <bits/stdc++.h> using namespace std; vector <char> vowels = { 'a', 'e', 'i', 'o', 'u', 'y' }; bool isVowel(char c) { return find(vowels.begin(), vowels.end(), c) != vowels.end(); } int main() { ios_base::sync_with_stdio(0); string s; cin >> s; int n = s.size(); vector <bool> seq(n); for (int i = 0; i < n; i++) { seq[i] = isVowel(s[i]); } int lastHard = -1; long long ans = 0; for (int i = 0; i < n; i++) { int sum = 0; if (i >= 2) { for (int j = i - 2; j <= i; j++) { sum += seq[j]; } if (sum == 0 || sum == 3) { lastHard = i - 2; } } ans += lastHard + 1; } cout << ans; return 0; } |