#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <utility>
#include <stack>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define FOR(v,p,k) for(int v=(p);v<=(k);++v)
#define FORD(v,p,k) for(int v=(p);v>=(k);--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define SIZE(x) (int)x.size()
#define ALL(c) c.begin(),c.end()
#define ODD(x) ((x)%2)
#define EVEN(x) (!(ODD(x)))
char s[200009];
inline bool is_vowel(char c) {
return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y');
}
int main() {
scanf("%s", s);
LL res=0;
int NO_VALUE=-1;
int last_hard_begin = NO_VALUE;
FOR(i, 2, strlen(s)-1) {
if ((is_vowel(s[i]) == is_vowel(s[i-1])) && (is_vowel(s[i]) == is_vowel(s[i-2]))) {
res += i-1;
last_hard_begin = i-2;
continue;
}
if (last_hard_begin != NO_VALUE) {
res += last_hard_begin+1;
continue;
}
}
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #include <cstdio> #include <cstring> #include <cmath> #include <cassert> #include <iostream> #include <algorithm> #include <iterator> #include <string> #include <vector> #include <queue> #include <bitset> #include <utility> #include <stack> using namespace std; typedef long long LL; typedef pair<int,int> PII; typedef vector<int> VI; #define MP make_pair #define FOR(v,p,k) for(int v=(p);v<=(k);++v) #define FORD(v,p,k) for(int v=(p);v>=(k);--v) #define REP(i,n) for(int i=0;i<(n);++i) #define VAR(v,i) __typeof(i) v=(i) #define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i) #define PB push_back #define ST first #define ND second #define SIZE(x) (int)x.size() #define ALL(c) c.begin(),c.end() #define ODD(x) ((x)%2) #define EVEN(x) (!(ODD(x))) char s[200009]; inline bool is_vowel(char c) { return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); } int main() { scanf("%s", s); LL res=0; int NO_VALUE=-1; int last_hard_begin = NO_VALUE; FOR(i, 2, strlen(s)-1) { if ((is_vowel(s[i]) == is_vowel(s[i-1])) && (is_vowel(s[i]) == is_vowel(s[i-2]))) { res += i-1; last_hard_begin = i-2; continue; } if (last_hard_begin != NO_VALUE) { res += last_hard_begin+1; continue; } } printf("%lld\n", res); return 0; } |
English