#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); string a; cin >> a; int n = a.size(); vector <char> w = {'a','e','i','o','u','y'}; vector <int> b(n); vector <int> d(n); for(int i = 0; i < n; ++i){ for(char c : w){ if(a[i] == c) b[i] = 1; } } vector <int> e(n); for(int i = 2; i < n; ++i){ if(b[i] == b[i-1] && b[i-2] == b[i]){ d[i-2] = 1; } } int x = -1; long long ans = 0; for(int i = n-1; i >= 0; --i){ if(d[i])x = i+2; if(x != -1){ ans += n - x; } } cout << ans << '\n'; }
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 | #include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); string a; cin >> a; int n = a.size(); vector <char> w = {'a','e','i','o','u','y'}; vector <int> b(n); vector <int> d(n); for(int i = 0; i < n; ++i){ for(char c : w){ if(a[i] == c) b[i] = 1; } } vector <int> e(n); for(int i = 2; i < n; ++i){ if(b[i] == b[i-1] && b[i-2] == b[i]){ d[i-2] = 1; } } int x = -1; long long ans = 0; for(int i = n-1; i >= 0; --i){ if(d[i])x = i+2; if(x != -1){ ans += n - x; } } cout << ans << '\n'; } |