#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; char sl[N]; long long result = 0; bool sam[N]; int main() { scanf("%s", sl); int n = strlen(sl); for (int i = 0; i < n; i++) for (char z: {'a', 'e', 'i', 'o', 'u', 'y'}) if (sl[i] == z) sam[i] = 1; int daleko = n; for (int i = n-3; i >= 0; i--) { if (sam[i] && sam[i+1] && sam[i+2]) daleko = i+2; if (!sam[i] && !sam[i+1] && !sam[i+2]) daleko = i+2; result += (long long)(n-daleko); } 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 | #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; char sl[N]; long long result = 0; bool sam[N]; int main() { scanf("%s", sl); int n = strlen(sl); for (int i = 0; i < n; i++) for (char z: {'a', 'e', 'i', 'o', 'u', 'y'}) if (sl[i] == z) sam[i] = 1; int daleko = n; for (int i = n-3; i >= 0; i--) { if (sam[i] && sam[i+1] && sam[i+2]) daleko = i+2; if (!sam[i] && !sam[i+1] && !sam[i+2]) daleko = i+2; result += (long long)(n-daleko); } printf("%lld\n", result); return 0; } |