#include<bits/stdc++.h> using namespace std; set<char> whitelist{'a', 'e', 'i', 'o', 'u', 'y'}; int main() { ios_base::sync_with_stdio(0); string S; cin >> S; long long int result = 0; int last_hard_pos = -1; for (int i = 2; i < S.length(); ++i) { int white = 0; for (int j = i-2; j <= i; ++j) { if (whitelist.count(S[j])) white++; } if (white == 0 || white == 3) last_hard_pos = i-2; result += last_hard_pos + 1; } cout << result << endl; 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 | #include<bits/stdc++.h> using namespace std; set<char> whitelist{'a', 'e', 'i', 'o', 'u', 'y'}; int main() { ios_base::sync_with_stdio(0); string S; cin >> S; long long int result = 0; int last_hard_pos = -1; for (int i = 2; i < S.length(); ++i) { int white = 0; for (int j = i-2; j <= i; ++j) { if (whitelist.count(S[j])) white++; } if (white == 0 || white == 3) last_hard_pos = i-2; result += last_hard_pos + 1; } cout << result << endl; return 0; } |