#include <cstdio>
using namespace std;
inline bool isVowel(char c) {
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y';
}
int main() {
char s[200001];
unsigned long p[200001];
unsigned long np = 0;
unsigned long long n = 0;
unsigned long cc = 0;
unsigned long vc = 0;
scanf("%s", s);
unsigned long i = 0;
for (char* current = s; *current != '\0'; current++) {
if (isVowel(*current)) {
vc++;
cc = 0;
} else {
cc++;
vc = 0;
}
if (cc > 2 || vc > 2) {
p[np] = i - 2;
np++;
}
i++;
}
if (np > 0) {
for (unsigned long j = 0; j < np-1; j++) {
unsigned long pos = p[j];
unsigned long npos = p[j+1];
unsigned long x = (pos + 1) * (npos - pos);
n += x;
}
unsigned long pos = p[np-1];
unsigned long x = (pos + 1) * (i - pos - 2);
n += x;
}
printf("%llu\n", n);
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 | #include <cstdio> using namespace std; inline bool isVowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { char s[200001]; unsigned long p[200001]; unsigned long np = 0; unsigned long long n = 0; unsigned long cc = 0; unsigned long vc = 0; scanf("%s", s); unsigned long i = 0; for (char* current = s; *current != '\0'; current++) { if (isVowel(*current)) { vc++; cc = 0; } else { cc++; vc = 0; } if (cc > 2 || vc > 2) { p[np] = i - 2; np++; } i++; } if (np > 0) { for (unsigned long j = 0; j < np-1; j++) { unsigned long pos = p[j]; unsigned long npos = p[j+1]; unsigned long x = (pos + 1) * (npos - pos); n += x; } unsigned long pos = p[np-1]; unsigned long x = (pos + 1) * (i - pos - 2); n += x; } printf("%llu\n", n); return 0; } |
English