#include <iostream>
#include <string>
using namespace std;
string c;
bool t[200003];
int ta[200003];
long long y,z,p=0,k=0,j=0;
int main()
{
std::ios_base::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>c;
y=c.size();
if(y<3)
{
cout<<0;
return 0;
}
else
{
for(int i=0;i<y;i++)
{
if(c[i]=='a'||c[i]=='e'||c[i]=='y'||c[i]=='o'||c[i]=='i'||c[i]=='u')
{
t[i]=true;
}
else
t[i]=false;
}
{
for(int i=0;i<=y-3;i++)
{
if(t[i]+t[i+1]+t[i+2]==3)
{
ta[k]=i;
k++;
}
else
if(t[i]+t[i+1]+t[i+2]==0)
{
ta[k]=i;
k++;
}
}
}
while(j<k)
{
while(p<=ta[j])
{
z+=(y-(ta[j]+2));
p++;
}
j++;
}
cout<<z;
}
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 <iostream> #include <string> using namespace std; string c; bool t[200003]; int ta[200003]; long long y,z,p=0,k=0,j=0; int main() { std::ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); cin>>c; y=c.size(); if(y<3) { cout<<0; return 0; } else { for(int i=0;i<y;i++) { if(c[i]=='a'||c[i]=='e'||c[i]=='y'||c[i]=='o'||c[i]=='i'||c[i]=='u') { t[i]=true; } else t[i]=false; } { for(int i=0;i<=y-3;i++) { if(t[i]+t[i+1]+t[i+2]==3) { ta[k]=i; k++; } else if(t[i]+t[i+1]+t[i+2]==0) { ta[k]=i; k++; } } } while(j<k) { while(p<=ta[j]) { z+=(y-(ta[j]+2)); p++; } j++; } cout<<z; } return 0; } |
English