#include <bits/stdc++.h> #include <sys/time.h> #define int long long #define ST first #define ND second #define pb push_back #define rep(i, a, n) for (int i = a; i <= n; i++) #define per(i, a, n) for (int i = a; i >= n; i--) #define SZ(x) ((int)x.size()) #define ALL(x) (x.begin(), x.end()) #define pii pair <int, int> #define ll long long #define LD long double using namespace std; string str; ll n, ost, ans; ll sam[1432]; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>str; if (str.size()<3) { cout<<0; return 0; } sam['a']=sam['e']=sam['i']=sam['u']=sam['o']=sam['y']=1; n = str.size(); str = '#'+str; ost = 0; for (ll i = 1; i <= n-2; i++) { if ((sam[str[i]]&&sam[str[i+1]]&&sam[str[i+2]]) || (!sam[str[i]]&&!sam[str[i+1]]&&!sam[str[i+2]])) { ans += (i-1-ost+1)*(n-(i+2)+1); ost = i; } } cout<<ans; }
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 | #include <bits/stdc++.h> #include <sys/time.h> #define int long long #define ST first #define ND second #define pb push_back #define rep(i, a, n) for (int i = a; i <= n; i++) #define per(i, a, n) for (int i = a; i >= n; i--) #define SZ(x) ((int)x.size()) #define ALL(x) (x.begin(), x.end()) #define pii pair <int, int> #define ll long long #define LD long double using namespace std; string str; ll n, ost, ans; ll sam[1432]; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>str; if (str.size()<3) { cout<<0; return 0; } sam['a']=sam['e']=sam['i']=sam['u']=sam['o']=sam['y']=1; n = str.size(); str = '#'+str; ost = 0; for (ll i = 1; i <= n-2; i++) { if ((sam[str[i]]&&sam[str[i+1]]&&sam[str[i+2]]) || (!sam[str[i]]&&!sam[str[i+1]]&&!sam[str[i+2]])) { ans += (i-1-ost+1)*(n-(i+2)+1); ost = i; } } cout<<ans; } |