#include <bits/stdc++.h> #include <random> #include <ext/pb_ds/assoc_container.hpp> //using namespace __gnu_pbds; using namespace std; #define ff first #define dd second #define mp make_pair #define lld long long #define pb emplace_back #define sz size() #define For(i,s,a) for(int i=(int)s;i<(int)a;++i) #define pii pair<int,int> #define pll pair<lld,lld> #define rpt(S,it) for(auto it=S.begin();it!=S.end();++it) #define mod (lld)(1e9+7) #define scanf(...) scanf(__VA_ARGS__)?:0 #define P first #define S second #ifdef __WIN32__ #define gcx getchar #elif __linux__ #define gcx getchar_unlocked #endif #define piii pair<pii,pii> //template<typename T> #define T int inline void scan(T *i) { register T t=0; register char z='a'; register bool neg=0; while(z<'0' || z>'9'){if(z=='-')neg^=1; z=gcx();} while(z>='0' && z<='9') { t=(t<<3ll)+(t<<1ll)+z-'0'; z=gcx(); } if(neg)t=~(t-1); *i=t; } char s[250001]; bool iok(char x) { if(x=='a' || x=='e' || x=='o' || x=='u' || x=='y' || x=='i') return 1; return 0; } int main() { scanf("%s",s); int a=strlen(s); lld wyn=0,prev=-1; For(i,0,a-2) { if(iok(s[i])==iok(s[i+1]) && iok(s[i+1])==iok(s[i+2])) //cout<<i<<" "<<prev-1<<" "<<a-1<<" "<<(i+2)-1<<endl, wyn+=(i-prev)*(a-(i+2)),prev=i; } printf("%lld",wyn); }
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 | #include <bits/stdc++.h> #include <random> #include <ext/pb_ds/assoc_container.hpp> //using namespace __gnu_pbds; using namespace std; #define ff first #define dd second #define mp make_pair #define lld long long #define pb emplace_back #define sz size() #define For(i,s,a) for(int i=(int)s;i<(int)a;++i) #define pii pair<int,int> #define pll pair<lld,lld> #define rpt(S,it) for(auto it=S.begin();it!=S.end();++it) #define mod (lld)(1e9+7) #define scanf(...) scanf(__VA_ARGS__)?:0 #define P first #define S second #ifdef __WIN32__ #define gcx getchar #elif __linux__ #define gcx getchar_unlocked #endif #define piii pair<pii,pii> //template<typename T> #define T int inline void scan(T *i) { register T t=0; register char z='a'; register bool neg=0; while(z<'0' || z>'9'){if(z=='-')neg^=1; z=gcx();} while(z>='0' && z<='9') { t=(t<<3ll)+(t<<1ll)+z-'0'; z=gcx(); } if(neg)t=~(t-1); *i=t; } char s[250001]; bool iok(char x) { if(x=='a' || x=='e' || x=='o' || x=='u' || x=='y' || x=='i') return 1; return 0; } int main() { scanf("%s",s); int a=strlen(s); lld wyn=0,prev=-1; For(i,0,a-2) { if(iok(s[i])==iok(s[i+1]) && iok(s[i+1])==iok(s[i+2])) //cout<<i<<" "<<prev-1<<" "<<a-1<<" "<<(i+2)-1<<endl, wyn+=(i-prev)*(a-(i+2)),prev=i; } printf("%lld",wyn); } |