// // main.cpp // JezykPolski // // Created by Cezary Chodun on 12/11/18. // Copyright © 2018 CCH. All rights reserved. // //#include <iostream> //#include <bitset> //#include <string> #include <bits/stdc++.h> using namespace std; #define ll long long #define int2 pair<int, int> #define mp make_pair #define X first #define Y second int n; bitset<200009> bts; void read(){ bts.reset(); string s; cin >> s; n = (int)s.size(); for(int i = 0; i < n; i++){ char c = s[i]; if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='y') bts[i] = 1; } } ll solve(){ ll out = 0; int start = 0; int a = 0, b = 0; for(int i = 0; i < n; i++){ if(bts[i] == 1){ a++; b = 0; } else{ a = 0; b++; } if(a>=3 || b>=3){ // cout << a << " " << b << "i = " << i << " left = " << (i-2-start+1) << " right = " << (n-i) << "\n"; out += (ll)(i-2-start+1)*(n-i); start = i-1; a = min(a, 2); b = min(b, 2); } } return out; } int main(){ read(); cout << solve() << "\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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | // // main.cpp // JezykPolski // // Created by Cezary Chodun on 12/11/18. // Copyright © 2018 CCH. All rights reserved. // //#include <iostream> //#include <bitset> //#include <string> #include <bits/stdc++.h> using namespace std; #define ll long long #define int2 pair<int, int> #define mp make_pair #define X first #define Y second int n; bitset<200009> bts; void read(){ bts.reset(); string s; cin >> s; n = (int)s.size(); for(int i = 0; i < n; i++){ char c = s[i]; if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='y') bts[i] = 1; } } ll solve(){ ll out = 0; int start = 0; int a = 0, b = 0; for(int i = 0; i < n; i++){ if(bts[i] == 1){ a++; b = 0; } else{ a = 0; b++; } if(a>=3 || b>=3){ // cout << a << " " << b << "i = " << i << " left = " << (i-2-start+1) << " right = " << (n-i) << "\n"; out += (ll)(i-2-start+1)*(n-i); start = i-1; a = min(a, 2); b = min(b, 2); } } return out; } int main(){ read(); cout << solve() << "\n"; return 0; } |