#include <bits/stdc++.h> using namespace std; #define PB push_back #define MP make_pair #define F first #define S second typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5e4 + 5; const int INF = 1e9 + 7; bool isVowel(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return true; return false; } void solve() { string s; cin >> s; int n = s.size(); if (n < 3) { cout << 0; exit(0); } vi pos; for (int i = 2; i < n; i++) { bool a = isVowel(s[i]); bool b = isVowel(s[i - 1]); bool c = isVowel(s[i - 2]); if (a + b + c == 0 || a + b + c == 3) { pos.PB(i); } } pos.PB(n); ll ans = 0; int goal = 0; for (int beg = 0; beg < n - 2; beg++) { while (beg + 2 > pos[goal]) { goal++; } ans += n - pos[goal]; } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); solve(); 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 50 51 52 53 54 55 56 57 58 59 | #include <bits/stdc++.h> using namespace std; #define PB push_back #define MP make_pair #define F first #define S second typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5e4 + 5; const int INF = 1e9 + 7; bool isVowel(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return true; return false; } void solve() { string s; cin >> s; int n = s.size(); if (n < 3) { cout << 0; exit(0); } vi pos; for (int i = 2; i < n; i++) { bool a = isVowel(s[i]); bool b = isVowel(s[i - 1]); bool c = isVowel(s[i - 2]); if (a + b + c == 0 || a + b + c == 3) { pos.PB(i); } } pos.PB(n); ll ans = 0; int goal = 0; for (int beg = 0; beg < n - 2; beg++) { while (beg + 2 > pos[goal]) { goal++; } ans += n - pos[goal]; } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); solve(); return 0; } |