#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
int n = (int) s.size();
set<char> vowels = {'a', 'o', 'u', 'e', 'y', 'i'};
long long result = 0;
int p = -1;
for (int i = 0; i < n - 2; ++i) {
int mask = 0;
for (int j = 0; j < 3; ++j)
mask |= (1 << j) * vowels.count(s[i + j]);
if (mask == 0 || mask == 7) {
result += 1LL * (i - p) * (n - i - 2);
p = i;
}
}
cout << result << '\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 | #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int n = (int) s.size(); set<char> vowels = {'a', 'o', 'u', 'e', 'y', 'i'}; long long result = 0; int p = -1; for (int i = 0; i < n - 2; ++i) { int mask = 0; for (int j = 0; j < 3; ++j) mask |= (1 << j) * vowels.count(s[i + j]); if (mask == 0 || mask == 7) { result += 1LL * (i - p) * (n - i - 2); p = i; } } cout << result << '\n'; } |
English