#include <cstdio> static constexpr int max_n = 200000; static char s[max_n + 2]; using LL = long long; int main() { char *p = s; while (EOF != (*p = getchar_unlocked())) ++p; *(p - 1) = '\0'; LL n = p - s - 1; for (int i = 0; i < n; i++) { switch (s[i]) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': s[i] = 'a'; break; default: s[i] = 'b'; } } LL count = 0, m = n - 1, prev = 0; for (int i = 1; i < m; i++) { if (s[i - 1] == s[i] && s[i] == s[i + 1]) { // printf("%lli %lli\n", (i - prev), (m - i)); count += (i - prev) * (m - i); prev = i; } } printf("%lli\n", count); }
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 | #include <cstdio> static constexpr int max_n = 200000; static char s[max_n + 2]; using LL = long long; int main() { char *p = s; while (EOF != (*p = getchar_unlocked())) ++p; *(p - 1) = '\0'; LL n = p - s - 1; for (int i = 0; i < n; i++) { switch (s[i]) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': s[i] = 'a'; break; default: s[i] = 'b'; } } LL count = 0, m = n - 1, prev = 0; for (int i = 1; i < m; i++) { if (s[i - 1] == s[i] && s[i] == s[i + 1]) { // printf("%lli %lli\n", (i - prev), (m - i)); count += (i - prev) * (m - i); prev = i; } } printf("%lli\n", count); } |