#include <iostream> #include <vector> using namespace std; using ll = long long; #define SIZE(c) static_cast<int>((c).size()) bool is_vowel(char c) { switch(c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return true; default: return false; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; cin>>s; const int n = SIZE(s); vector<bool> v(n); for(int i=0;i<n;++i) v[i] = is_vowel(s[i]); int last_block = -1; ll ans = 0; for(int i=2;i<n;++i) { if(v[i-2] == v[i] && v[i-1] == v[i]) last_block = i-2; ans += last_block + 1; } 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 | #include <iostream> #include <vector> using namespace std; using ll = long long; #define SIZE(c) static_cast<int>((c).size()) bool is_vowel(char c) { switch(c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return true; default: return false; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; cin>>s; const int n = SIZE(s); vector<bool> v(n); for(int i=0;i<n;++i) v[i] = is_vowel(s[i]); int last_block = -1; ll ans = 0; for(int i=2;i<n;++i) { if(v[i-2] == v[i] && v[i-1] == v[i]) last_block = i-2; ans += last_block + 1; } cout << ans << endl; } |