#include <bits/stdc++.h> #include <unordered_set> using namespace std; #define st first #define nd second #define pb push_back #define mp make_pair #define klar(v) memset(v, 0, sizeof(v)) #define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define gcd(a, b) __gcd(a, b); #define debug(x) cout << #x << " " << x << endl; #define endl "\n" typedef vector<int> vi; typedef vector<pair<int, int> > vpii; typedef vector<long long> vll; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef long long ll; const int maxn = 5e5+100; map <char, int> M; int arr[maxn]; int main(){ bust M['a'] = M['e'] = M['i'] = M['o'] = M['u'] = 1; string s; cin >> s; for(int i = 0; i < s.size(); i++) if(M[s[i]])arr[i] = 1; int prev = -1; ll ans = 0; for(int i = 2; i < s.size(); i++){ if(arr[i] == arr[i-1] and arr[i-1] == arr[i-2]){ prev = i-2; } if(prev != -1){ ans += 1LL*(prev+1); } } cout << ans << endl; }
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 | #include <bits/stdc++.h> #include <unordered_set> using namespace std; #define st first #define nd second #define pb push_back #define mp make_pair #define klar(v) memset(v, 0, sizeof(v)) #define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define gcd(a, b) __gcd(a, b); #define debug(x) cout << #x << " " << x << endl; #define endl "\n" typedef vector<int> vi; typedef vector<pair<int, int> > vpii; typedef vector<long long> vll; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef long long ll; const int maxn = 5e5+100; map <char, int> M; int arr[maxn]; int main(){ bust M['a'] = M['e'] = M['i'] = M['o'] = M['u'] = 1; string s; cin >> s; for(int i = 0; i < s.size(); i++) if(M[s[i]])arr[i] = 1; int prev = -1; ll ans = 0; for(int i = 2; i < s.size(); i++){ if(arr[i] == arr[i-1] and arr[i-1] == arr[i-2]){ prev = i-2; } if(prev != -1){ ans += 1LL*(prev+1); } } cout << ans << endl; } |