#include <cstdio> #include <cstring> using namespace std; char s[200001]; int main() { scanf("%s", s); int n = strlen(s); long long result = 0; auto is_sam = [&](char c) { return (c == 'a' || c == 'o' || c == 'e' || c == 'i' || c == 'u' || c == 'y'); }; int eq = 1, last = 0; for (int i = 1; i < n; i++) { if (is_sam(s[i]) == is_sam(s[i-1])) { eq++; } else { eq = 1; } if (eq >= 3) { last = i-1; } result += last; } printf("%lld\n", result); }
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 | #include <cstdio> #include <cstring> using namespace std; char s[200001]; int main() { scanf("%s", s); int n = strlen(s); long long result = 0; auto is_sam = [&](char c) { return (c == 'a' || c == 'o' || c == 'e' || c == 'i' || c == 'u' || c == 'y'); }; int eq = 1, last = 0; for (int i = 1; i < n; i++) { if (is_sam(s[i]) == is_sam(s[i-1])) { eq++; } else { eq = 1; } if (eq >= 3) { last = i-1; } result += last; } printf("%lld\n", result); } |