#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 7; char Tab[N]; string s; bool Vowel (char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y' || c == 'o'; } bool Check (int i) { bool a = Vowel(s[i]), b = Vowel(s[i + 1]), c = Vowel(s[i + 2]); return (a == b && b == c); } void Solve () { int n = s.size(), it = 0; LL result = 0LL; for (int i = 0; i < n; ++i) { it = max(it, i); while (it < n - 2 && !Check(it)) ++it; if (it >= n - 2) break; result += (LL)(n - it - 2); } printf("%lld", result); } int main () { scanf("%s", Tab); s = Tab; Solve(); 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 | #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 7; char Tab[N]; string s; bool Vowel (char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y' || c == 'o'; } bool Check (int i) { bool a = Vowel(s[i]), b = Vowel(s[i + 1]), c = Vowel(s[i + 2]); return (a == b && b == c); } void Solve () { int n = s.size(), it = 0; LL result = 0LL; for (int i = 0; i < n; ++i) { it = max(it, i); while (it < n - 2 && !Check(it)) ++it; if (it >= n - 2) break; result += (LL)(n - it - 2); } printf("%lld", result); } int main () { scanf("%s", Tab); s = Tab; Solve(); return 0; } |