#include <bits/stdc++.h> using namespace std; typedef long long int LL; const int N = 2e5 + 7; string s; LL res = 0LL; bool type[N]; LL newton(LL a){ return a * (a + 1) / 2; } int main(){ type['a'] = type['e'] = type['i'] = type['o'] = type['u'] = type['y'] = true; ios_base::sync_with_stdio(false); cin >> s; if(s.size() < 3){ cout << "0\n"; return 0; } int last = s.size(); res = 3; for(int i = s.size() - 3; i >= 0; --i){ bool bad = type[s[i]] == type[s[i + 1]] && type[s[i]] == type[s[i + 2]]; if(bad) last = min(last, i + 2); res += last - i; } cout << newton(s.size()) - 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 | #include <bits/stdc++.h> using namespace std; typedef long long int LL; const int N = 2e5 + 7; string s; LL res = 0LL; bool type[N]; LL newton(LL a){ return a * (a + 1) / 2; } int main(){ type['a'] = type['e'] = type['i'] = type['o'] = type['u'] = type['y'] = true; ios_base::sync_with_stdio(false); cin >> s; if(s.size() < 3){ cout << "0\n"; return 0; } int last = s.size(); res = 3; for(int i = s.size() - 3; i >= 0; --i){ bool bad = type[s[i]] == type[s[i + 1]] && type[s[i]] == type[s[i + 2]]; if(bad) last = min(last, i + 2); res += last - i; } cout << newton(s.size()) - res << "\n"; return 0; } |