#include<bits/stdc++.h> #define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++) #define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--) #define MAGICLINE ios_base::sync_with_stdio(0) #define pb push_back #define mp make_pair #define se second #define fs first using namespace std; typedef long long LL; typedef long double LD; typedef pair<int, int> PII; typedef pair<LL, int> PLI; typedef priority_queue<int> PQI; typedef priority_queue<LL> PQL; typedef priority_queue<PLI, vector<PLI>, greater<PLI> > dijQ; const char vowels[] = {'a', 'e', 'i', 'o', 'u', 'y'}; vector<int> T; bool isVowel(char a){ rep(i, 0, 6) if(a == vowels[i]) return true; return false; } int main(){ MAGICLINE; string a; cin >> a; int n = a.size(), coun = 0; T.pb(-1); bool thisVowel = false, lastVowel = false; rep(i, 0, n){ thisVowel = isVowel(a[i]); if(!(lastVowel ^ thisVowel)) coun++; else coun = 1; lastVowel = thisVowel; if(coun >= 3) T.pb(i-2); } LL res = 0; rep(i, 1, T.size()) res += (LL)(T[i]-T[i-1])*(n-T[i]-2); cout << res << "\n"; 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> #define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++) #define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--) #define MAGICLINE ios_base::sync_with_stdio(0) #define pb push_back #define mp make_pair #define se second #define fs first using namespace std; typedef long long LL; typedef long double LD; typedef pair<int, int> PII; typedef pair<LL, int> PLI; typedef priority_queue<int> PQI; typedef priority_queue<LL> PQL; typedef priority_queue<PLI, vector<PLI>, greater<PLI> > dijQ; const char vowels[] = {'a', 'e', 'i', 'o', 'u', 'y'}; vector<int> T; bool isVowel(char a){ rep(i, 0, 6) if(a == vowels[i]) return true; return false; } int main(){ MAGICLINE; string a; cin >> a; int n = a.size(), coun = 0; T.pb(-1); bool thisVowel = false, lastVowel = false; rep(i, 0, n){ thisVowel = isVowel(a[i]); if(!(lastVowel ^ thisVowel)) coun++; else coun = 1; lastVowel = thisVowel; if(coun >= 3) T.pb(i-2); } LL res = 0; rep(i, 1, T.size()) res += (LL)(T[i]-T[i-1])*(n-T[i]-2); cout << res << "\n"; return 0; } |