#include <stdio.h> /* just in case */ #define LEN 200007 char buf[LEN]; char type(char c) { switch (c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return 0x01; default: return 0x10; } } int hard(int pos) { if (pos < 2) return 0; return type(buf[pos]) & type(buf[pos - 1]) & type(buf[pos - 2]); } int main() { int i = 0, last_hard = LEN; long long int res = 0; scanf("%s", buf); while (buf[i]) { if (hard(i)) last_hard = i; if (last_hard <= i) res += last_hard - 1; i++; } printf("%lld\n", res); 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 | #include <stdio.h> /* just in case */ #define LEN 200007 char buf[LEN]; char type(char c) { switch (c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return 0x01; default: return 0x10; } } int hard(int pos) { if (pos < 2) return 0; return type(buf[pos]) & type(buf[pos - 1]) & type(buf[pos - 2]); } int main() { int i = 0, last_hard = LEN; long long int res = 0; scanf("%s", buf); while (buf[i]) { if (hard(i)) last_hard = i; if (last_hard <= i) res += last_hard - 1; i++; } printf("%lld\n", res); return 0; } |