#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 200005; inline bool samo(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { ios_base::sync_with_stdio(0); string s; cin >> s; int n = s.size(); vector<int> V; V.reserve(maxn); for(int i = 0; i < n - 2;i++) { bool czy = samo(s[i]); if(samo(s[i + 1]) == czy && samo(s[i + 2]) == czy) V.push_back(i); } V.push_back(n - 2); ll ans = 0; for(int i = 0; i < V.size() - 1; i++) { int pos = V[i]; ans += (pos + 1) * (V[i + 1] - pos); } 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 33 34 35 36 37 38 | #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 200005; inline bool samo(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { ios_base::sync_with_stdio(0); string s; cin >> s; int n = s.size(); vector<int> V; V.reserve(maxn); for(int i = 0; i < n - 2;i++) { bool czy = samo(s[i]); if(samo(s[i + 1]) == czy && samo(s[i + 2]) == czy) V.push_back(i); } V.push_back(n - 2); ll ans = 0; for(int i = 0; i < V.size() - 1; i++) { int pos = V[i]; ans += (pos + 1) * (V[i + 1] - pos); } cout << ans << endl; return 0; } |