#include <bits/stdc++.h>
using namespace std;
char s[200001];
bool sp(char c) {
return (c == 'a' || c == 'e' || c == 'o' || c == 'u' || c == 'i' || c == 'y');
}
int main() {
scanf("%s", s);
int l = 0, dl = strlen(s);
int samo = 0, spol = 0;
long long wynik = 0;
for (int i = 0; i < 3; i++)
if (sp(s[i]))
samo++;
else
spol++;
if (samo == 3 || spol == 3) {
wynik += dl-2;
//printf("D %lld\n", wynik);
l = 1;
}
for (int i = 3; i < dl; i++) {
if (sp(s[i-3]))
samo--;
else
spol--;
if (sp(s[i]))
samo++;
else
spol++;
if (samo == 3 || spol == 3) {
//printf("%s\n", s+i-2);
wynik += (i-l-1)*(dl-i);
l = i-1;
}
}
printf("%lld", wynik);
}
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 | #include <bits/stdc++.h> using namespace std; char s[200001]; bool sp(char c) { return (c == 'a' || c == 'e' || c == 'o' || c == 'u' || c == 'i' || c == 'y'); } int main() { scanf("%s", s); int l = 0, dl = strlen(s); int samo = 0, spol = 0; long long wynik = 0; for (int i = 0; i < 3; i++) if (sp(s[i])) samo++; else spol++; if (samo == 3 || spol == 3) { wynik += dl-2; //printf("D %lld\n", wynik); l = 1; } for (int i = 3; i < dl; i++) { if (sp(s[i-3])) samo--; else spol--; if (sp(s[i])) samo++; else spol++; if (samo == 3 || spol == 3) { //printf("%s\n", s+i-2); wynik += (i-l-1)*(dl-i); l = i-1; } } printf("%lld", wynik); } |
English