#include<iostream>
using namespace std;
bool czy(char a){
if (a=='a' || a=='e' || a=='i' || a=='y' || a=='o' ||a=='u')
return true;
return false;
}
bool testuj(bool a, bool b, bool c){
if (a && b && !c)
return true;
if (a && !b && !c)
return true;
if (!a && b && c)
return true;
if (!a && !b && c)
return true;
if (a && !b && c)
return true;
if (!a && b && !c)
return true;
return false;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
string slowo;
cin >>slowo;
int d= slowo.size();
long long l,p=0;
long long suma,ile=0;
suma = (d - 2)*(d-1)/2;
// cout<<suma<<endl;
l=0;
for (int i=0;i<d-2;i++){
if (testuj(czy(slowo[i]), czy(slowo[i+1]) , czy(slowo[i+2])))
p++;
else{
ile=(p-l+1)*(p-l)/2;
// cout <<l<<" "<<p<<" "<<ile<<endl;
suma-=ile;
l=p=i ;
}
}
if(p-l>0)
suma-=(p-l+1)*(p-l)/2;
cout <<suma<<endl;
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 | #include<iostream> using namespace std; bool czy(char a){ if (a=='a' || a=='e' || a=='i' || a=='y' || a=='o' ||a=='u') return true; return false; } bool testuj(bool a, bool b, bool c){ if (a && b && !c) return true; if (a && !b && !c) return true; if (!a && b && c) return true; if (!a && !b && c) return true; if (a && !b && c) return true; if (!a && b && !c) return true; return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string slowo; cin >>slowo; int d= slowo.size(); long long l,p=0; long long suma,ile=0; suma = (d - 2)*(d-1)/2; // cout<<suma<<endl; l=0; for (int i=0;i<d-2;i++){ if (testuj(czy(slowo[i]), czy(slowo[i+1]) , czy(slowo[i+2]))) p++; else{ ile=(p-l+1)*(p-l)/2; // cout <<l<<" "<<p<<" "<<ile<<endl; suma-=ile; l=p=i ; } } if(p-l>0) suma-=(p-l+1)*(p-l)/2; cout <<suma<<endl; return 0; } |
English