#include<bits/stdc++.h> #define FOR(i,a,b) for(int i=a;i<b;++i) #define FOROP(i,a,b,op) for(int i=a;i<b;op) #define FORD(i,a,b) for(int i=a;i>=b;--i) #define PB push_back #define FI first #define SE second #define umap unordered_map #define uset unordered_set #define vi vector<int> #define vii vector<vi> #define pii pair<int, int> #define ALL(X) (X).begin(),(X).end() #ifndef DEBUG #define endl (char)10 #endif using namespace std; using ll = long long; bool samogl(char x){ return x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y'; } bool check(string & s, int i){ return (samogl(s[i]) && samogl(s[i - 1]) && samogl(s[i - 2])) || (!samogl(s[i]) && !samogl(s[i - 1]) && !samogl(s[i - 2])); } int main () { ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; ll last = 1; ll ans = 0; int n = s.size(); FOR(i,2,n){ if (check(s, i)){ ans += (i - last) * (n - i); last = i; } } 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> #define FOR(i,a,b) for(int i=a;i<b;++i) #define FOROP(i,a,b,op) for(int i=a;i<b;op) #define FORD(i,a,b) for(int i=a;i>=b;--i) #define PB push_back #define FI first #define SE second #define umap unordered_map #define uset unordered_set #define vi vector<int> #define vii vector<vi> #define pii pair<int, int> #define ALL(X) (X).begin(),(X).end() #ifndef DEBUG #define endl (char)10 #endif using namespace std; using ll = long long; bool samogl(char x){ return x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y'; } bool check(string & s, int i){ return (samogl(s[i]) && samogl(s[i - 1]) && samogl(s[i - 2])) || (!samogl(s[i]) && !samogl(s[i - 1]) && !samogl(s[i - 2])); } int main () { ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; ll last = 1; ll ans = 0; int n = s.size(); FOR(i,2,n){ if (check(s, i)){ ans += (i - last) * (n - i); last = i; } } cout << ans << endl; } |