#include <cstdio> #include <cstring> #include <cctype> #define MAX_N 200000 #define REP(a, b) for (int (a)=0; (a)<(b); (a)++) char str[MAX_N+1]; int n; void load_input() { scanf("%s", str); n = strlen(str); REP(i, n) str[i] = tolower(str[i]); } bool is_vowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } bool hard_one(int i) { bool isv[3]; isv[0] = is_vowel(str[i]); isv[1] = is_vowel(str[i+1]); isv[2] = is_vowel(str[i+2]); return (isv[0] && isv[1] && isv[2]) || (!isv[0] && !isv[1] && !isv[2]); } int main() { load_input(); long long result = 0; int last = 0; REP(i, n-2) { if (hard_one(i)) { result += (i+1-last)*(n-i-2); last = i+1; } } printf("%lld\n", 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 | #include <cstdio> #include <cstring> #include <cctype> #define MAX_N 200000 #define REP(a, b) for (int (a)=0; (a)<(b); (a)++) char str[MAX_N+1]; int n; void load_input() { scanf("%s", str); n = strlen(str); REP(i, n) str[i] = tolower(str[i]); } bool is_vowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } bool hard_one(int i) { bool isv[3]; isv[0] = is_vowel(str[i]); isv[1] = is_vowel(str[i+1]); isv[2] = is_vowel(str[i+2]); return (isv[0] && isv[1] && isv[2]) || (!isv[0] && !isv[1] && !isv[2]); } int main() { load_input(); long long result = 0; int last = 0; REP(i, n-2) { if (hard_one(i)) { result += (i+1-last)*(n-i-2); last = i+1; } } printf("%lld\n", result); return 0; } |