#include<iostream> #include<cstring> using namespace std; int main() { ios_base::sync_with_stdio(0); char a[200000]; bool b[200000]; cin>>a; int _size=strlen(a); //cout<<_size<<endl; int il; int lb=-1, ab=-1; int w=0; for(int i=0;i<_size;i++) { if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='y')b[i]=0; else b[i]=1; if(i>=2&&b[i]==b[i-1]&&b[i-1]==b[i-2]) { //cout<<a[i-2]<<a[i-1]<<a[i]<<endl; lb=ab; ab=i; w+=(ab-1)*(_size-ab); //cout<<w<<" "<<ab<<endl; if(lb!=-1) { w-=(lb-1)*(_size-ab); } //cout<<w<<endl; } } cout<<w; }
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 | #include<iostream> #include<cstring> using namespace std; int main() { ios_base::sync_with_stdio(0); char a[200000]; bool b[200000]; cin>>a; int _size=strlen(a); //cout<<_size<<endl; int il; int lb=-1, ab=-1; int w=0; for(int i=0;i<_size;i++) { if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='y')b[i]=0; else b[i]=1; if(i>=2&&b[i]==b[i-1]&&b[i-1]==b[i-2]) { //cout<<a[i-2]<<a[i-1]<<a[i]<<endl; lb=ab; ab=i; w+=(ab-1)*(_size-ab); //cout<<w<<" "<<ab<<endl; if(lb!=-1) { w-=(lb-1)*(_size-ab); } //cout<<w<<endl; } } cout<<w; } |