#include <cstdio>
#include <cstring>
using namespace std;
typedef long long LL;
const int MAX = 2e5;
char s[MAX+1];
LL n, r;
bool vow(char c) {
switch (c) {
case 'a': return true;
case 'e': return true;
case 'i': return true;
case 'o': return true;
case 'u': return true;
case 'y': return true;
}
return false;
}
bool same(char a, char b, char c) {
return vow(a) == vow(b) && vow(b) == vow(c);
}
bool ok(int i, int j) {
return j-i >= 3 && same(s[j-3], s[j-2], s[j-1]);
}
int main() {
scanf("%s", s);
n = strlen(s);
for (int i=0, j=0; i < n; ++i) {
while (j<n && !ok(i, j)) ++j;
if (ok(i, j)) r += n-j+1;
}
printf("%lld\n", r);
}
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 <cstdio> #include <cstring> using namespace std; typedef long long LL; const int MAX = 2e5; char s[MAX+1]; LL n, r; bool vow(char c) { switch (c) { case 'a': return true; case 'e': return true; case 'i': return true; case 'o': return true; case 'u': return true; case 'y': return true; } return false; } bool same(char a, char b, char c) { return vow(a) == vow(b) && vow(b) == vow(c); } bool ok(int i, int j) { return j-i >= 3 && same(s[j-3], s[j-2], s[j-1]); } int main() { scanf("%s", s); n = strlen(s); for (int i=0, j=0; i < n; ++i) { while (j<n && !ok(i, j)) ++j; if (ok(i, j)) r += n-j+1; } printf("%lld\n", r); } |
English