#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i = (a); i <= (b); ++i) #define FORD(i,a,b) for(int i = (a); i >= (b); --i) #define RI(i,n) FOR(i,1,(n)) #define REP(i,n) FOR(i,0,(n)-1) #define mini(a,b) a=min(a,b) #define maxi(a,b) a=max(a,b) #define mp make_pair #define pb push_back #define st first #define nd second #define sz(w) (int) w.size() typedef vector<int> vi; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<pii, int> para; const int inf = 1e9 + 7; const int maxN = 5e6 + 5; string s; bool isVowel(int i) { return (s[i] == 'a' || s[i] == 'e' || s[i] == 'o' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y'); } int main() { ios_base::sync_with_stdio(0); cin >> s; int n = s.size(); ll sum = 0; ll last = -1; for (int i = 2; i < n; i++) { if ((isVowel(i) && isVowel(i - 1) && isVowel(i - 2)) || (!isVowel(i) && !isVowel(i - 1) && !isVowel(i - 2))) { last = i - 2; } if (last != -1) { sum += (last + 1); } } cout << sum << 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 39 40 41 42 43 44 45 46 47 48 | #include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i = (a); i <= (b); ++i) #define FORD(i,a,b) for(int i = (a); i >= (b); --i) #define RI(i,n) FOR(i,1,(n)) #define REP(i,n) FOR(i,0,(n)-1) #define mini(a,b) a=min(a,b) #define maxi(a,b) a=max(a,b) #define mp make_pair #define pb push_back #define st first #define nd second #define sz(w) (int) w.size() typedef vector<int> vi; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<pii, int> para; const int inf = 1e9 + 7; const int maxN = 5e6 + 5; string s; bool isVowel(int i) { return (s[i] == 'a' || s[i] == 'e' || s[i] == 'o' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y'); } int main() { ios_base::sync_with_stdio(0); cin >> s; int n = s.size(); ll sum = 0; ll last = -1; for (int i = 2; i < n; i++) { if ((isVowel(i) && isVowel(i - 1) && isVowel(i - 2)) || (!isVowel(i) && !isVowel(i - 1) && !isVowel(i - 2))) { last = i - 2; } if (last != -1) { sum += (last + 1); } } cout << sum << endl; return 0; } |