#include <iostream> #include <string> #include <fstream> #include <vector> using namespace std; int main() { string s; cin >> s; int n = s.size(); vector<int> type(256, 0); type['a'] = type['e'] = type['i'] = type['o'] = type['u'] = type['y'] = 1; vector<int> bad(n, 0); for(int i = 0; i + 2 < n; i += 1) { if(type[s[i]] == type[s[i + 1]] and type[s[i]] == type[s[i + 2]]) { bad[i] = 1; } } int64_t ans = 0; int it = 0; for(int i = 0; i < n; i += 1) { it = max(it, i); while(it < n and not bad[it]) { it += 1; } ans += max(0, (n - (it + 2))); } cout << ans << "\n"; }
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 | #include <iostream> #include <string> #include <fstream> #include <vector> using namespace std; int main() { string s; cin >> s; int n = s.size(); vector<int> type(256, 0); type['a'] = type['e'] = type['i'] = type['o'] = type['u'] = type['y'] = 1; vector<int> bad(n, 0); for(int i = 0; i + 2 < n; i += 1) { if(type[s[i]] == type[s[i + 1]] and type[s[i]] == type[s[i + 2]]) { bad[i] = 1; } } int64_t ans = 0; int it = 0; for(int i = 0; i < n; i += 1) { it = max(it, i); while(it < n and not bad[it]) { it += 1; } ans += max(0, (n - (it + 2))); } cout << ans << "\n"; } |