#include <iostream> using namespace std; using ll = long long; const int MAXN = 2e5 + 5; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; for (char &c : s) { if (c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u' or c == 'y') { c = '0'; } else { c = '1'; } } int n = s.size(); int closest = n - 2; ll res = 0; for (int i = n - 3; i >= 0; i--) { if (s[i] == s[i + 1] and s[i] == s[i + 2]) { closest = i; } res += (n - 2 - closest); } cout << res << "\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 35 36 | #include <iostream> using namespace std; using ll = long long; const int MAXN = 2e5 + 5; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; for (char &c : s) { if (c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u' or c == 'y') { c = '0'; } else { c = '1'; } } int n = s.size(); int closest = n - 2; ll res = 0; for (int i = n - 3; i >= 0; i--) { if (s[i] == s[i + 1] and s[i] == s[i + 2]) { closest = i; } res += (n - 2 - closest); } cout << res << "\n"; } |