#include <cstdio> #include <cassert> #include <set> #include <algorithm> #include <cstring> const int M = 201013; int samo(char x) { if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y') return 1; return 2; } int main() { char s[M]; scanf("%s", s); int n = strlen(s); long long ret = 0; int p = 0; for (int i = 0; i+2 < n; i++) { if (samo(s[i]) == samo(s[i+1]) && samo(s[i]) == samo(s[i+2])) { ret += ((long long)(i-p+1)) * (n-i-2); p = i+1; } } printf("%lld\n", ret); }
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 | #include <cstdio> #include <cassert> #include <set> #include <algorithm> #include <cstring> const int M = 201013; int samo(char x) { if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y') return 1; return 2; } int main() { char s[M]; scanf("%s", s); int n = strlen(s); long long ret = 0; int p = 0; for (int i = 0; i+2 < n; i++) { if (samo(s[i]) == samo(s[i+1]) && samo(s[i]) == samo(s[i+2])) { ret += ((long long)(i-p+1)) * (n-i-2); p = i+1; } } printf("%lld\n", ret); } |