#include <bits/stdc++.h> using namespace std; bool isVovel(char c) { return c == 'a' || c == 'y' || c == 'i' || c == 'u' || c == 'e' || c == 'o'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; long long ans = 0; long long n = s.size(); vector<int> bad(n + 10); for (int a = 2; a < n; a++) { if (isVovel(s[a]) && isVovel(s[a - 1]) && isVovel(s[a - 2])) bad[a + 1] = 1; if (!isVovel(s[a]) && !isVovel(s[a - 1]) && !isVovel(s[a - 2])) bad[a + 1] = 1; } int las = 0; for (int a = n; a >= 1; a--) { if (bad[a + 2]) las = a + 2; if (las) { ans += n - las + 1; } } cout << ans << 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 | #include <bits/stdc++.h> using namespace std; bool isVovel(char c) { return c == 'a' || c == 'y' || c == 'i' || c == 'u' || c == 'e' || c == 'o'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; long long ans = 0; long long n = s.size(); vector<int> bad(n + 10); for (int a = 2; a < n; a++) { if (isVovel(s[a]) && isVovel(s[a - 1]) && isVovel(s[a - 2])) bad[a + 1] = 1; if (!isVovel(s[a]) && !isVovel(s[a - 1]) && !isVovel(s[a - 2])) bad[a + 1] = 1; } int las = 0; for (int a = n; a >= 1; a--) { if (bad[a + 2]) las = a + 2; if (las) { ans += n - las + 1; } } cout << ans << endl; return 0; } |