#include <cstdio> #include <cstring> #define MAX_W 200010 char w[MAX_W]; int b, c, l, v; long long f; int main() { scanf("%s", w); l = strlen(w); for (int i = 0; i < l; i++) { if (w[i] == 'a' || w[i] == 'e' || w[i] == 'i' || w[i] == 'o' || w[i] == 'u' || w[i] == 'y') { if (v) { c++; } else { v = 1; c = 1; } } else { if (v) { v = 0; c = 1; } else { c++; } } if (c >= 3) { f += 1LL * (i - b - 1) * (l - i); b = i - 1; } } printf("%lld\n", f); 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 | #include <cstdio> #include <cstring> #define MAX_W 200010 char w[MAX_W]; int b, c, l, v; long long f; int main() { scanf("%s", w); l = strlen(w); for (int i = 0; i < l; i++) { if (w[i] == 'a' || w[i] == 'e' || w[i] == 'i' || w[i] == 'o' || w[i] == 'u' || w[i] == 'y') { if (v) { c++; } else { v = 1; c = 1; } } else { if (v) { v = 0; c = 1; } else { c++; } } if (c >= 3) { f += 1LL * (i - b - 1) * (l - i); b = i - 1; } } printf("%lld\n", f); return 0; } |