#include <bits/stdc++.h> #define FOR(i, a, b) for (int (i)=(a); (i)<(b); (i)++) #define PPC(x) __builtin_popcountll((x)) #define ALL(x) (x).begin(), (x).end() #define pb push_back using namespace std; const int maxN = 200042; char T[maxN]; int tp[30]; void filltp() { tp['a' - 'a'] = tp['e' - 'a'] = tp['i' - 'a'] = tp['o' - 'a'] = tp['u' - 'a'] = tp['y' - 'a'] = 1; } int getp(int i) { return tp[T[i] - 'a']; } int main() { filltp(); scanf ("%s", T); int n = strlen(T), End = n; long long res = 0; for (int i=n-3; i>=0; i--) { if (getp(i) == getp(i+1) and getp(i) == getp(i+2)) End = i + 2; res += n - End; } printf("%lld\n", res); 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 | #include <bits/stdc++.h> #define FOR(i, a, b) for (int (i)=(a); (i)<(b); (i)++) #define PPC(x) __builtin_popcountll((x)) #define ALL(x) (x).begin(), (x).end() #define pb push_back using namespace std; const int maxN = 200042; char T[maxN]; int tp[30]; void filltp() { tp['a' - 'a'] = tp['e' - 'a'] = tp['i' - 'a'] = tp['o' - 'a'] = tp['u' - 'a'] = tp['y' - 'a'] = 1; } int getp(int i) { return tp[T[i] - 'a']; } int main() { filltp(); scanf ("%s", T); int n = strlen(T), End = n; long long res = 0; for (int i=n-3; i>=0; i--) { if (getp(i) == getp(i+1) and getp(i) == getp(i+2)) End = i + 2; res += n - End; } printf("%lld\n", res); return 0; } |