#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
string str;
cin>>str;
int dlsl=str.size();
int tabsl[200005];
for(int i=0; i<dlsl; i++){
if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='y'){
tabsl[i]=1;
}
else{
tabsl[i]=0;
}
}
int tymsam=0;
int tymspl=0;
vector<int> pozkontr;
if(tabsl[0])tymsam=1;
else tymspl=1;
for(int i=1; i<dlsl; i++){
if(tabsl[i]){
tymsam++;
tymspl=0;
}
else{
tymsam=0;
tymspl++;
}
if(tymsam>=3 || tymspl>=3){
pozkontr.push_back(i);
}
}
int vecsize=pozkontr.size();
long long wyn=0;
int temp=0;
if(vecsize>0){
for(int i=0; i<dlsl; i++){
if(temp>=vecsize)break;
if(i>pozkontr[temp]-2)temp++;
if(temp>=vecsize)break;
if(i<=pozkontr[temp]-2){
wyn+=dlsl-pozkontr[temp];
}
}
}
cout<<wyn;
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 | #include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios_base::sync_with_stdio(0); string str; cin>>str; int dlsl=str.size(); int tabsl[200005]; for(int i=0; i<dlsl; i++){ if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='y'){ tabsl[i]=1; } else{ tabsl[i]=0; } } int tymsam=0; int tymspl=0; vector<int> pozkontr; if(tabsl[0])tymsam=1; else tymspl=1; for(int i=1; i<dlsl; i++){ if(tabsl[i]){ tymsam++; tymspl=0; } else{ tymsam=0; tymspl++; } if(tymsam>=3 || tymspl>=3){ pozkontr.push_back(i); } } int vecsize=pozkontr.size(); long long wyn=0; int temp=0; if(vecsize>0){ for(int i=0; i<dlsl; i++){ if(temp>=vecsize)break; if(i>pozkontr[temp]-2)temp++; if(temp>=vecsize)break; if(i<=pozkontr[temp]-2){ wyn+=dlsl-pozkontr[temp]; } } } cout<<wyn; return 0; } |
English