#include <bits/stdc++.h> #define rep(i,a,b) for (int i=a; i<b; i++) #define pb push_back #define mp make_pair #define fi first #define se second #define mitte (lewy+prawy)/2 #define debug // using namespace std; typedef long long ll; typedef long double ld; vector <int> poz; //pozycje , gdzie zlo sie dzieje string s; int samo (char c) { if (c=='a') return 1; if (c=='e') return 1; if (c=='i') return 1; if (c=='o') return 1; if (c=='u') return 1; if (c=='y') return 1; return 0; } int main () { cin>>s; int n=s.size(); rep(i,0,n-2) { if (samo(s[i])==samo(s[i+1])) if (samo(s[i])==samo(s[i+2])) poz.pb(i); } ll ok=0; ll m; if ((int)poz.size()==0) { cout<<0 <<"\n"; return 0; } m=poz[0]+2; ok+=m*(m-1LL); debug ("m = %lld\n", m); rep(i,0,(int)poz.size()-1) { if (poz[i]+1==poz[i+1]) { m=2; } else { m=poz[i+1]-poz[i]+1; } ok+=m*(m-1LL); debug ("m = %lld\n", m); } m=n-poz[(int)poz.size()-1]-1; debug ("m = %lld\n", m); ok+=m*(m-1LL); m=n; debug ("%d\n", n); debug ("ok jest %lld vs %lld\n", ok, (m*(m-1LL))); cout<<(m*(m-1LL)-ok)/2LL <<"\n"; }
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 | #include <bits/stdc++.h> #define rep(i,a,b) for (int i=a; i<b; i++) #define pb push_back #define mp make_pair #define fi first #define se second #define mitte (lewy+prawy)/2 #define debug // using namespace std; typedef long long ll; typedef long double ld; vector <int> poz; //pozycje , gdzie zlo sie dzieje string s; int samo (char c) { if (c=='a') return 1; if (c=='e') return 1; if (c=='i') return 1; if (c=='o') return 1; if (c=='u') return 1; if (c=='y') return 1; return 0; } int main () { cin>>s; int n=s.size(); rep(i,0,n-2) { if (samo(s[i])==samo(s[i+1])) if (samo(s[i])==samo(s[i+2])) poz.pb(i); } ll ok=0; ll m; if ((int)poz.size()==0) { cout<<0 <<"\n"; return 0; } m=poz[0]+2; ok+=m*(m-1LL); debug ("m = %lld\n", m); rep(i,0,(int)poz.size()-1) { if (poz[i]+1==poz[i+1]) { m=2; } else { m=poz[i+1]-poz[i]+1; } ok+=m*(m-1LL); debug ("m = %lld\n", m); } m=n-poz[(int)poz.size()-1]-1; debug ("m = %lld\n", m); ok+=m*(m-1LL); m=n; debug ("%d\n", n); debug ("ok jest %lld vs %lld\n", ok, (m*(m-1LL))); cout<<(m*(m-1LL)-ok)/2LL <<"\n"; } |