#include <tuple> #include <vector> #include <stdio.h> #include <iostream> #include <algorithm> #include <functional> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int,int>; using vi = vector<int>; using vb = vector<bool>; using vc = vector<char>; using vvi = vector<vi>; using vpii = vector<pii>; using vll = vector<ll>; using vull = vector<ull>; #define ever (;;) #define f first #define s second #define pb emplace_back #define graph vector<vertex> #define deg(X) G[X].e.size() #define INF 1234567890 #define INFll 2000000000000000000 #define maxe(X, Y) if((Y) > (X)) (X) = (Y) #define mine(X, Y) if((Y) < (X)) (X) = (Y) #define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i) #define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i) #define bend(X) X.begin(), X.end() ll n; vb T; void in() { string s; cin >> s; n = s.size(); T.resize(n); rep(i, 0, n) if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u' || s[i]=='y') T[i] = 1; else T[i] = 0; } int main() { in(); ll all = n*(n+1)/2; ll R = (n==1?1:3); // latwe int j = 0; rep(i, 2, n) { if(T[i] == T[i-1] && T[i] == T[i-2]) j = i-1; R += i-j+1; } printf("%lld\n", all-R); 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #include <tuple> #include <vector> #include <stdio.h> #include <iostream> #include <algorithm> #include <functional> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int,int>; using vi = vector<int>; using vb = vector<bool>; using vc = vector<char>; using vvi = vector<vi>; using vpii = vector<pii>; using vll = vector<ll>; using vull = vector<ull>; #define ever (;;) #define f first #define s second #define pb emplace_back #define graph vector<vertex> #define deg(X) G[X].e.size() #define INF 1234567890 #define INFll 2000000000000000000 #define maxe(X, Y) if((Y) > (X)) (X) = (Y) #define mine(X, Y) if((Y) < (X)) (X) = (Y) #define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i) #define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i) #define bend(X) X.begin(), X.end() ll n; vb T; void in() { string s; cin >> s; n = s.size(); T.resize(n); rep(i, 0, n) if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u' || s[i]=='y') T[i] = 1; else T[i] = 0; } int main() { in(); ll all = n*(n+1)/2; ll R = (n==1?1:3); // latwe int j = 0; rep(i, 2, n) { if(T[i] == T[i-1] && T[i] == T[i-2]) j = i-1; R += i-j+1; } printf("%lld\n", all-R); return 0; } |