#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
char samo[10];
long long pref[3000005];
void check(char a,char b,char c,long long xd)
{
int pom=0;
for(int x=0;x<6;x++)
{
if(a==samo[x])
pom++;
if(b==samo[x])
pom++;
if(c==samo[x])
pom++;
}
if(pom==0||pom==3)
v.push_back(xd);
}
void fil()
{
samo[0]='a';
samo[1]='e';
samo[2]='i';
samo[3]='o';
samo[4]='u';
samo[5]='y';
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
fil();
string a;
cin>>a;
v.push_back(42);
v.push_back(1);
for(long long x=1;x<a.size()-1;x++)
check(a[x-1],a[x],a[x+1],x+1);
v.push_back(a.size());
if(v.size()==3)
cout<<0;
else
{
long long out=0;
for(int x=1;x<v.size();x++)
pref[x]=pref[x-1]+v[x];
for(int x=2;x<v.size()-1;x++)
out-=v[x]*(pref[v.size()-2]-pref[x-1]);
for(int x=1;x<v.size()-2;x++)
out+=v[x]*(pref[v.size()-2]-pref[x]);
for(int x=2;x<=v.size()-1;x++)
out+=v[x]*(pref[v.size()-1]-pref[x]);
for(int x=1;x<v.size()-2;x++)
out-=v[x]*(pref[v.size()-1]-pref[x+1]);
cout<<out;
}
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<bits/stdc++.h> using namespace std; vector<long long> v; char samo[10]; long long pref[3000005]; void check(char a,char b,char c,long long xd) { int pom=0; for(int x=0;x<6;x++) { if(a==samo[x]) pom++; if(b==samo[x]) pom++; if(c==samo[x]) pom++; } if(pom==0||pom==3) v.push_back(xd); } void fil() { samo[0]='a'; samo[1]='e'; samo[2]='i'; samo[3]='o'; samo[4]='u'; samo[5]='y'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); fil(); string a; cin>>a; v.push_back(42); v.push_back(1); for(long long x=1;x<a.size()-1;x++) check(a[x-1],a[x],a[x+1],x+1); v.push_back(a.size()); if(v.size()==3) cout<<0; else { long long out=0; for(int x=1;x<v.size();x++) pref[x]=pref[x-1]+v[x]; for(int x=2;x<v.size()-1;x++) out-=v[x]*(pref[v.size()-2]-pref[x-1]); for(int x=1;x<v.size()-2;x++) out+=v[x]*(pref[v.size()-2]-pref[x]); for(int x=2;x<=v.size()-1;x++) out+=v[x]*(pref[v.size()-1]-pref[x]); for(int x=1;x<v.size()-2;x++) out-=v[x]*(pref[v.size()-1]-pref[x+1]); cout<<out; } return 0; } |
English