#include <bits/stdc++.h>
using namespace std;
int main() {
set<char> vovels = {'a', 'e', 'i', 'o', 'u', 'y'};
ios_base::sync_with_stdio(0);
string str;
cin >> str;
vector<bool> abc(str.size());
for (int i = 0; i < str.size(); i++) {
abc[i] = vovels.find(str[i]) == vovels.end();
}
int i = 0, j = 1, ile = 1;
while (j < abc.size() && ile < 3) {
if (abc[j] == abc[j - 1]) {
ile++;
} else {
ile = 1;
}
j++;
}
long long res = 0;
bool flag = true;
while (true) {
if (j - i < 3) {
j -= 1;
ile = 1;
while (j < abc.size() && ile < 3) {
if (abc[j] == abc[j - 1]) {
ile++;
} else {
ile = 1;
}
j++;
}
if (ile < 3) {
break;
};
}
res += abc.size() - j + 1;
i++;
}
cout << res;
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <bits/stdc++.h> using namespace std; int main() { set<char> vovels = {'a', 'e', 'i', 'o', 'u', 'y'}; ios_base::sync_with_stdio(0); string str; cin >> str; vector<bool> abc(str.size()); for (int i = 0; i < str.size(); i++) { abc[i] = vovels.find(str[i]) == vovels.end(); } int i = 0, j = 1, ile = 1; while (j < abc.size() && ile < 3) { if (abc[j] == abc[j - 1]) { ile++; } else { ile = 1; } j++; } long long res = 0; bool flag = true; while (true) { if (j - i < 3) { j -= 1; ile = 1; while (j < abc.size() && ile < 3) { if (abc[j] == abc[j - 1]) { ile++; } else { ile = 1; } j++; } if (ile < 3) { break; }; } res += abc.size() - j + 1; i++; } cout << res; return 0; } |
English