#include <bits/stdc++.h> using namespace std; #define PB push_back #define FORE(i, t) for(__typeof(t.begin())i=t.begin();i!=t.end();++i) #define SZ(x) int((x).size()) #define REP(i, n) for(int i=0,_=(n);i<_;++i) #define FOR(i, a, b) for(int i=(a),_=(b);i<=_;++i) #define FORD(i, a, b) for(int i=(a),_=(b);i>=_;--i) #ifdef DEBUG #define DEB(x) (cerr << x) #else #define DEB(x) #endif typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; const int INF = 1e9 + 9; bool is_vowel[256] = {}; void inline one() { string s; cin >> s; int n = SZ(s); // cout << n << "\n"; int same_count = 1; int last_group = -1; ll result = 0; REP (i, n) { DEB("i=" << i << " " << s[i] << " " << is_vowel[int(s[i])] << "\n"); if (i > 0) { if (is_vowel[int(s[i])] == is_vowel[int(s[i - 1])]) { ++same_count; } else { same_count = 1; } } if (same_count >= 3) { last_group = i; } int new_words = last_group - 1; DEB("same=" << same_count << " last_group=" << last_group << " new_words=" << new_words << "\n"); if (new_words > 0) { result += new_words; } } cout << result << "\n"; } int main() { FORE(it, string("aeiouy")) { is_vowel[int(*it)] = true; } // FOR(c, 'a', 'z') { // cout << char(c) << " " << is_vowel[c] << "\n"; // } ios::sync_with_stdio(false); //int z; cin >> z; while(z--) one(); }
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 | #include <bits/stdc++.h> using namespace std; #define PB push_back #define FORE(i, t) for(__typeof(t.begin())i=t.begin();i!=t.end();++i) #define SZ(x) int((x).size()) #define REP(i, n) for(int i=0,_=(n);i<_;++i) #define FOR(i, a, b) for(int i=(a),_=(b);i<=_;++i) #define FORD(i, a, b) for(int i=(a),_=(b);i>=_;--i) #ifdef DEBUG #define DEB(x) (cerr << x) #else #define DEB(x) #endif typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; const int INF = 1e9 + 9; bool is_vowel[256] = {}; void inline one() { string s; cin >> s; int n = SZ(s); // cout << n << "\n"; int same_count = 1; int last_group = -1; ll result = 0; REP (i, n) { DEB("i=" << i << " " << s[i] << " " << is_vowel[int(s[i])] << "\n"); if (i > 0) { if (is_vowel[int(s[i])] == is_vowel[int(s[i - 1])]) { ++same_count; } else { same_count = 1; } } if (same_count >= 3) { last_group = i; } int new_words = last_group - 1; DEB("same=" << same_count << " last_group=" << last_group << " new_words=" << new_words << "\n"); if (new_words > 0) { result += new_words; } } cout << result << "\n"; } int main() { FORE(it, string("aeiouy")) { is_vowel[int(*it)] = true; } // FOR(c, 'a', 'z') { // cout << char(c) << " " << is_vowel[c] << "\n"; // } ios::sync_with_stdio(false); //int z; cin >> z; while(z--) one(); } |