#include<bits/stdc++.h> using namespace std; string in; vector < pair <int , int> > parts; long long s,temp = 0,wynik; bool tab[((int)(1e6))+1]; bool notTemp[((int)(1e6))+1]; bool isThis(char c){ char tab[6] = { 'a', 'e', 'y', 'i', 'o', 'u' }; for(int i=0;i<6;i++){ if(c == tab[i]){ return 1; } } return 0; } int main(){ ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin>>in; s = in.size(); parts.push_back(make_pair(0, 0)); for(int i=0;i<s;i++){ tab[i] = isThis(in[i]); } for(int i=2;i<s;i++){ if((tab[i] == tab[i-1]) && (tab[i-1] == tab[i-2]) && (tab[i] == tab[i-2])) { notTemp[i+1] = 1; } } for(int i=s;i>=1;i--){ if(notTemp[i+2] >= 1){ temp = i+2; } if(temp >= 1) wynik += s-temp+1; } cout<<wynik; 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 | #include<bits/stdc++.h> using namespace std; string in; vector < pair <int , int> > parts; long long s,temp = 0,wynik; bool tab[((int)(1e6))+1]; bool notTemp[((int)(1e6))+1]; bool isThis(char c){ char tab[6] = { 'a', 'e', 'y', 'i', 'o', 'u' }; for(int i=0;i<6;i++){ if(c == tab[i]){ return 1; } } return 0; } int main(){ ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin>>in; s = in.size(); parts.push_back(make_pair(0, 0)); for(int i=0;i<s;i++){ tab[i] = isThis(in[i]); } for(int i=2;i<s;i++){ if((tab[i] == tab[i-1]) && (tab[i-1] == tab[i-2]) && (tab[i] == tab[i-2])) { notTemp[i+1] = 1; } } for(int i=s;i>=1;i--){ if(notTemp[i+2] >= 1){ temp = i+2; } if(temp >= 1) wynik += s-temp+1; } cout<<wynik; return 0; } |