#include <cstdio> #include <cstdlib> #include <cstdint> inline bool isletter(char c) { return (c >= 'a') && (c <= 'z'); } inline bool isvowel(char c) { return (c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u') || (c == 'y'); } uint64_t solve() { int c; while (!isletter(c = getchar())); uint32_t buffer = isvowel(c) ? 2 : 0; // Second character if (!isletter(c = getchar())) { return 0; } buffer |= isvowel(c) ? 1 : 0; uint64_t hits = 0; uint32_t lastGoodPos = 0, currPos = 0; // Other characters while (isletter(c = getchar())) { currPos++; buffer = ((buffer << 1) | (isvowel(c) ? 1 : 0)) & 7; if ((buffer == 0) || (buffer == 7)) { lastGoodPos = currPos; } hits += (uint64_t)lastGoodPos; } return hits; } int main() { const auto result = solve(); printf("%llu\n", (unsigned long long int)result); 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 | #include <cstdio> #include <cstdlib> #include <cstdint> inline bool isletter(char c) { return (c >= 'a') && (c <= 'z'); } inline bool isvowel(char c) { return (c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u') || (c == 'y'); } uint64_t solve() { int c; while (!isletter(c = getchar())); uint32_t buffer = isvowel(c) ? 2 : 0; // Second character if (!isletter(c = getchar())) { return 0; } buffer |= isvowel(c) ? 1 : 0; uint64_t hits = 0; uint32_t lastGoodPos = 0, currPos = 0; // Other characters while (isletter(c = getchar())) { currPos++; buffer = ((buffer << 1) | (isvowel(c) ? 1 : 0)) & 7; if ((buffer == 0) || (buffer == 7)) { lastGoodPos = currPos; } hits += (uint64_t)lastGoodPos; } return hits; } int main() { const auto result = solve(); printf("%llu\n", (unsigned long long int)result); return 0; } |