#include <bits/stdc++.h> using namespace std; string sl; bool tab[200005]; vector<int>lic; long long wyn,ost,pom; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>sl; int dl=sl.size(); for (int i=0; i<dl; i++){ if (sl[i]=='a'||sl[i]=='e'||sl[i]=='i'||sl[i]=='o'||sl[i]=='u'||sl[i]=='y'){tab[i]=1;} } for (int i=2; i<dl; i++){ if (tab[i]==tab[i-1]&&tab[i-1]==tab[i-2]) lic.push_back(i+1); } for (int i=0; i<lic.size(); i++){ pom=(lic[i]-2-ost)*(dl-lic[i]+1); wyn+=pom; ost=lic[i]-2; } 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 | #include <bits/stdc++.h> using namespace std; string sl; bool tab[200005]; vector<int>lic; long long wyn,ost,pom; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>sl; int dl=sl.size(); for (int i=0; i<dl; i++){ if (sl[i]=='a'||sl[i]=='e'||sl[i]=='i'||sl[i]=='o'||sl[i]=='u'||sl[i]=='y'){tab[i]=1;} } for (int i=2; i<dl; i++){ if (tab[i]==tab[i-1]&&tab[i-1]==tab[i-2]) lic.push_back(i+1); } for (int i=0; i<lic.size(); i++){ pom=(lic[i]-2-ost)*(dl-lic[i]+1); wyn+=pom; ost=lic[i]-2; } cout<<wyn; return 0; } |