//Krzysztof Boryczka
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)(x).size())
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'
#define WATCH(x) cout<<(#x)<<" is "<<(x)<<ent
//END OF TEMPLATE
bool who[200], pret[200010];
int t[200010];
vi sam={'a', 'e', 'i', 'o', 'u', 'y'};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
string s;
ll odp=0;
int j=0;
for(auto x: sam){
who[x]=true;
}
cin>>s;
FOR(i, 0, SIZE(s)-1){
pret[i+1]=who[s[i]];
}
FOR(i, 1, SIZE(s)-2){
if(pret[i]==pret[i+1] && pret[i+1]==pret[i+2]){
if(pret[i]==true){
t[i]=t[i+1]=t[i+2]=1;
}
else{
t[i]=t[i+1]=t[i+2]=2;
}
}
}
FOR(i, 1, SIZE(s)){
j=max(j, i+2);
while(!(t[j]==t[j-1]&&t[j-1]==t[j-2]&&t[j]) && j<=SIZE(s)){
j++;
}
if(j>SIZE(s)){
break;
}
odp+=SIZE(s)-j+1;
}
cout<<odp<<ent;
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 62 63 64 | //Krzysztof Boryczka #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; const int inf=0x3f3f3f3f; const ll INF=0x3f3f3f3f3f3f3f3f; #define FOR(i, b, e) for(int i=b; i<=e; i++) #define FORD(i, b, e) for(int i=b; i>=e; i--) #define SIZE(x) ((int)(x).size()) #define pb push_back #define st first #define nd second #define sp ' ' #define ent '\n' #define WATCH(x) cout<<(#x)<<" is "<<(x)<<ent //END OF TEMPLATE bool who[200], pret[200010]; int t[200010]; vi sam={'a', 'e', 'i', 'o', 'u', 'y'}; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; ll odp=0; int j=0; for(auto x: sam){ who[x]=true; } cin>>s; FOR(i, 0, SIZE(s)-1){ pret[i+1]=who[s[i]]; } FOR(i, 1, SIZE(s)-2){ if(pret[i]==pret[i+1] && pret[i+1]==pret[i+2]){ if(pret[i]==true){ t[i]=t[i+1]=t[i+2]=1; } else{ t[i]=t[i+1]=t[i+2]=2; } } } FOR(i, 1, SIZE(s)){ j=max(j, i+2); while(!(t[j]==t[j-1]&&t[j-1]==t[j-2]&&t[j]) && j<=SIZE(s)){ j++; } if(j>SIZE(s)){ break; } odp+=SIZE(s)-j+1; } cout<<odp<<ent; return 0; } |
English