#include<bits/stdc++.h> using namespace std; string a; bool sprawdz(int x) { if((a[x]=='a' || a[x]=='e' || a[x]=='i' || a[x]=='o' || a[x]=='u' || a[x]=='y') && (a[x+1]=='a' || a[x+1]=='e' || a[x+1]=='i' || a[x+1]=='o' || a[x+1]=='u' || a[x+1]=='y') && (a[x+2]=='a' || a[x+2]=='e' || a[x+2]=='i' || a[x+2]=='o' || a[x+2]=='u' || a[x+2]=='y')) { return true; } if(a[x]!='a' && a[x]!='e' && a[x]!='i' && a[x]!='o' && a[x]!='u' && a[x]!='y' && a[x+1]!='a' && a[x+1]!='e' && a[x+1]!='i' && a[x+1]!='o' && a[x+1]!='u' && a[x+1]!='y' && a[x+2]!='a' && a[x+2]!='e' && a[x+2]!='i' && a[x+2]!='o' && a[x+2]!='u' && a[x+2]!='y') { return true; } return false; } queue <long long> kolejka; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>a; for(int i=0; i<a.size()-2; ++i) { if(sprawdz(i)==1) { kolejka.push(i+1); } } long long licznik=0; long long wynik=0; long long n=a.size(); while(!kolejka.empty()) { long long x=kolejka.front(); x+=2; wynik+=n-x+1; if(x-2==licznik+1) { kolejka.pop(); } licznik++; } 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 | #include<bits/stdc++.h> using namespace std; string a; bool sprawdz(int x) { if((a[x]=='a' || a[x]=='e' || a[x]=='i' || a[x]=='o' || a[x]=='u' || a[x]=='y') && (a[x+1]=='a' || a[x+1]=='e' || a[x+1]=='i' || a[x+1]=='o' || a[x+1]=='u' || a[x+1]=='y') && (a[x+2]=='a' || a[x+2]=='e' || a[x+2]=='i' || a[x+2]=='o' || a[x+2]=='u' || a[x+2]=='y')) { return true; } if(a[x]!='a' && a[x]!='e' && a[x]!='i' && a[x]!='o' && a[x]!='u' && a[x]!='y' && a[x+1]!='a' && a[x+1]!='e' && a[x+1]!='i' && a[x+1]!='o' && a[x+1]!='u' && a[x+1]!='y' && a[x+2]!='a' && a[x+2]!='e' && a[x+2]!='i' && a[x+2]!='o' && a[x+2]!='u' && a[x+2]!='y') { return true; } return false; } queue <long long> kolejka; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>a; for(int i=0; i<a.size()-2; ++i) { if(sprawdz(i)==1) { kolejka.push(i+1); } } long long licznik=0; long long wynik=0; long long n=a.size(); while(!kolejka.empty()) { long long x=kolejka.front(); x+=2; wynik+=n-x+1; if(x-2==licznik+1) { kolejka.pop(); } licznik++; } cout<<wynik; return 0; } |