#include <bits/stdc++.h> #define PB push_back #define MP make_pair #define st first #define nd second #define umap unordered_map #define uset unordered_set #define watch(x) cerr << (#x) << " is " << (x) << endl #define all(a) begin(a),end(a) using namespace std; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; const int inf=0x3f3f3f3f; const long long llinf=0x3f3f3f3f3f3f3f3f; const double oo=1e15; const double eps=1e-8; const double pi=acos(-1.0); template<typename T> T sqr(T a_) { return a_*a_; } template<typename T> T cub(T a_) { return a_*a_*a_; } // inline void readI(int*n){register char c=0,sign=1;while(c<33)c=getchar_unlocked();if(c=='-'){sign=-1;c=getchar_unlocked();}*n=0;while(c>33){*n*=10;*n+=c-'0';c=getchar_unlocked();}*n*=sign;} // inline void printI(int n){if(!n){putchar_unlocked('0');return;}if(n<0){putchar_unlocked('-');n*=-1;}char digits[12];int i=0;while(n){digits[i++]=(n%10)+'0';n/=10;}while(i--)putchar_unlocked(digits[i]);} // inline void readLL(long long*n){register char c=0,sign=1;while(c<33)c=getchar_unlocked();if(c=='-'){sign=-1;c=getchar_unlocked();}*n=0;while(c>33){*n*=10;*n+=c-'0';c=getchar_unlocked();}*n*=sign;} // inline void printLL(long long n){if(!n){putchar_unlocked('0');return;}if(n<0){putchar_unlocked('-');n*=-1;}char digits[24];int i=0;while(n){digits[i++]=(n%10)+'0';n/=10;}while(i--)putchar_unlocked(digits[i]);} // inline void readS(string*s){register char c=0;while(c<33)c=getchar_unlocked();while(c>=33){*s+=c;c=getchar_unlocked();}} // inline void printS(string s){for(auto c:s)putchar_unlocked(c);} typedef long double ld; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; //-----------------------------------------------// const int N=0; const int M=0; const int K=0; char vov[6]={'a','e','i','o','u','y'}; bool ok(char a, char b, char c){ bool va=0,vb=0,vc=0; for(int i=0; i<6; i++){ if(a==vov[i]) va=1; if(b==vov[i]) vb=1; if(c==vov[i]) vc=1; } if((va && vb && vc) || (!va && !vb && !vc)){ return 0; } else{ return 1; } } int main(){ ios::sync_with_stdio(0); cin.tie(0); string s; cin>>s; ll len=s.length(); if(len==1){ cout<<0; return 0; } ll pos=0; ll res=len*(len+1)/2; for(ll i=0; i<len-2; i++){ if(!ok(s[i],s[i+1],s[i+2])){ res-=(i+1-pos+1)*(i+1-pos+2)/2-1; pos=i+1; } } res-=(len-pos)*(len-pos+1)/2; cout<<res<<'\n'; 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #include <bits/stdc++.h> #define PB push_back #define MP make_pair #define st first #define nd second #define umap unordered_map #define uset unordered_set #define watch(x) cerr << (#x) << " is " << (x) << endl #define all(a) begin(a),end(a) using namespace std; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; const int inf=0x3f3f3f3f; const long long llinf=0x3f3f3f3f3f3f3f3f; const double oo=1e15; const double eps=1e-8; const double pi=acos(-1.0); template<typename T> T sqr(T a_) { return a_*a_; } template<typename T> T cub(T a_) { return a_*a_*a_; } // inline void readI(int*n){register char c=0,sign=1;while(c<33)c=getchar_unlocked();if(c=='-'){sign=-1;c=getchar_unlocked();}*n=0;while(c>33){*n*=10;*n+=c-'0';c=getchar_unlocked();}*n*=sign;} // inline void printI(int n){if(!n){putchar_unlocked('0');return;}if(n<0){putchar_unlocked('-');n*=-1;}char digits[12];int i=0;while(n){digits[i++]=(n%10)+'0';n/=10;}while(i--)putchar_unlocked(digits[i]);} // inline void readLL(long long*n){register char c=0,sign=1;while(c<33)c=getchar_unlocked();if(c=='-'){sign=-1;c=getchar_unlocked();}*n=0;while(c>33){*n*=10;*n+=c-'0';c=getchar_unlocked();}*n*=sign;} // inline void printLL(long long n){if(!n){putchar_unlocked('0');return;}if(n<0){putchar_unlocked('-');n*=-1;}char digits[24];int i=0;while(n){digits[i++]=(n%10)+'0';n/=10;}while(i--)putchar_unlocked(digits[i]);} // inline void readS(string*s){register char c=0;while(c<33)c=getchar_unlocked();while(c>=33){*s+=c;c=getchar_unlocked();}} // inline void printS(string s){for(auto c:s)putchar_unlocked(c);} typedef long double ld; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; //-----------------------------------------------// const int N=0; const int M=0; const int K=0; char vov[6]={'a','e','i','o','u','y'}; bool ok(char a, char b, char c){ bool va=0,vb=0,vc=0; for(int i=0; i<6; i++){ if(a==vov[i]) va=1; if(b==vov[i]) vb=1; if(c==vov[i]) vc=1; } if((va && vb && vc) || (!va && !vb && !vc)){ return 0; } else{ return 1; } } int main(){ ios::sync_with_stdio(0); cin.tie(0); string s; cin>>s; ll len=s.length(); if(len==1){ cout<<0; return 0; } ll pos=0; ll res=len*(len+1)/2; for(ll i=0; i<len-2; i++){ if(!ok(s[i],s[i+1],s[i+2])){ res-=(i+1-pos+1)*(i+1-pos+2)/2-1; pos=i+1; } } res-=(len-pos)*(len-pos+1)/2; cout<<res<<'\n'; return 0; } //-----------------------------------------------// |