#include"bits/stdc++.h" using namespace std; #define debug if(0) #define watch(x) debug cout << __LINE__ << ": " << (#x) << " is " << (x) << endl ; #define watch_tab(x,n) debug { cout << __LINE__ << ": " << (#x) << " is "; \ for(int very_long_index=0;very_long_index<n;very_long_index++){ cout << x[very_long_index] << ", ";}\ cout << endl; } typedef long long ll; typedef unsigned long long ull; #define check(x,i) (x[i]=='a'||x[i]=='e'||x[i]=='i'||x[i]=='o'||x[i]=='u'||x[i]=='y') int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string a; cin >> a; ll sum=0,sam=0,spol=0,prev=0; for (int i = 0; i < a.size(); ++i) { if(check(a,i)){ spol=0; ++sam; } else { sam=0; ++spol; } if(sam>=3||spol>=3){ sum+=(i-prev-1)*(a.size()-i); prev=i-1; } } cout << sum; }
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 | #include"bits/stdc++.h" using namespace std; #define debug if(0) #define watch(x) debug cout << __LINE__ << ": " << (#x) << " is " << (x) << endl ; #define watch_tab(x,n) debug { cout << __LINE__ << ": " << (#x) << " is "; \ for(int very_long_index=0;very_long_index<n;very_long_index++){ cout << x[very_long_index] << ", ";}\ cout << endl; } typedef long long ll; typedef unsigned long long ull; #define check(x,i) (x[i]=='a'||x[i]=='e'||x[i]=='i'||x[i]=='o'||x[i]=='u'||x[i]=='y') int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string a; cin >> a; ll sum=0,sam=0,spol=0,prev=0; for (int i = 0; i < a.size(); ++i) { if(check(a,i)){ spol=0; ++sam; } else { sam=0; ++spol; } if(sam>=3||spol>=3){ sum+=(i-prev-1)*(a.size()-i); prev=i-1; } } cout << sum; } |