#include<iostream> using namespace std; int main() { int *tab = new int[200000]; string s1; long long int par=0,npar=0,wynik=0,zap=0,ost; cin>>s1; for(int i=0;i<s1.length();i++) { if(s1[i]=='a' || s1[i]=='e' || s1[i]=='u' || s1[i]=='o' || s1[i]=='i' || s1[i]=='y') tab[i]=0; else tab[i]=1; } for(int i=0;i<s1.length();i++) { if(tab[i]==0) { if(npar>0) { npar=0; zap=i; } par++; } else { if(par>0) { par=0; zap=i; } npar++; }//cout<<i<<" "<<par<<" "<<npar<<endl; if(par>=3 || npar>=3) { if(npar>3 || npar>3) { if(npar>3) npar=3; else par=3; } if(wynik==0) { wynik=wynik+s1.length()-2+((zap)*(s1.length()-(zap+3))); ost=zap; if(par>0) par=2; else npar=2; zap++; } else { wynik=wynik+(zap-ost)*(1+s1.length()-(zap+3)); ost=zap; if(par>0) par=2; else npar=2; zap++; } } } cout<<wynik; }
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 65 66 67 68 69 | #include<iostream> using namespace std; int main() { int *tab = new int[200000]; string s1; long long int par=0,npar=0,wynik=0,zap=0,ost; cin>>s1; for(int i=0;i<s1.length();i++) { if(s1[i]=='a' || s1[i]=='e' || s1[i]=='u' || s1[i]=='o' || s1[i]=='i' || s1[i]=='y') tab[i]=0; else tab[i]=1; } for(int i=0;i<s1.length();i++) { if(tab[i]==0) { if(npar>0) { npar=0; zap=i; } par++; } else { if(par>0) { par=0; zap=i; } npar++; }//cout<<i<<" "<<par<<" "<<npar<<endl; if(par>=3 || npar>=3) { if(npar>3 || npar>3) { if(npar>3) npar=3; else par=3; } if(wynik==0) { wynik=wynik+s1.length()-2+((zap)*(s1.length()-(zap+3))); ost=zap; if(par>0) par=2; else npar=2; zap++; } else { wynik=wynik+(zap-ost)*(1+s1.length()-(zap+3)); ost=zap; if(par>0) par=2; else npar=2; zap++; } } } cout<<wynik; } |