/* Dejwo to ziomal ®© */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector <ll> vi; typedef pair <ll, ll> pi; typedef vector<pair<ll,ll>> vpi; #define pb push_back #define FOR0(n) for(int i = 0; i < n; i++) #define FOR0j(n) for(int j = 0; j < n; j++) #define FOR1(n) for(int i = 1; i <= n; i++) #define FOR1j(n) for(int j = 1; j <= n; j++) #define FOR_REV(n) for(int i = n - 1; i >= 0 ; i--) #define FOR_REVj(n) for(int j = n - 1; j >= 0 ; j--) #define SIZE 200042 #define MAX 1e6 + 42 char samogloski[6] = {'a', 'e', 'i', 'o', 'u', 'y'}; bool czy_samogloska(char a){ FOR0(6) if( samogloski[ i ] == a) return true; return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; int n = 0; ll ans = 0; int last = 0; cin >> s; n = (int)s.size(); int near[ n ]; FOR0(n){ near[ i ] = -42; bool b1 = czy_samogloska( s[i] ); if( b1 ) s[i] = '0'; else s[i] = '1'; } FOR0(n - 2){ bool sam = s[ i ] == '0' and s[ i + 1 ] == '0' and s[ i + 2 ] == '0'; bool spol = s[ i ] == '1' and s[ i + 1 ] == '1' and s[ i + 2 ] == '1'; if( sam or spol ){ for(int pos = last; pos <= i; pos ++ ) near[ pos ] = i; last = i + 1; } } // cout << s << endl; // cout << n << endl; // FOR0(n) cout << near [ i ] << " "; // cout << endl; FOR0(n) if( near[ i ] >= 0) ans += n - near[ i ] - 2; cout << ans << endl; 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 | /* Dejwo to ziomal ®© */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector <ll> vi; typedef pair <ll, ll> pi; typedef vector<pair<ll,ll>> vpi; #define pb push_back #define FOR0(n) for(int i = 0; i < n; i++) #define FOR0j(n) for(int j = 0; j < n; j++) #define FOR1(n) for(int i = 1; i <= n; i++) #define FOR1j(n) for(int j = 1; j <= n; j++) #define FOR_REV(n) for(int i = n - 1; i >= 0 ; i--) #define FOR_REVj(n) for(int j = n - 1; j >= 0 ; j--) #define SIZE 200042 #define MAX 1e6 + 42 char samogloski[6] = {'a', 'e', 'i', 'o', 'u', 'y'}; bool czy_samogloska(char a){ FOR0(6) if( samogloski[ i ] == a) return true; return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; int n = 0; ll ans = 0; int last = 0; cin >> s; n = (int)s.size(); int near[ n ]; FOR0(n){ near[ i ] = -42; bool b1 = czy_samogloska( s[i] ); if( b1 ) s[i] = '0'; else s[i] = '1'; } FOR0(n - 2){ bool sam = s[ i ] == '0' and s[ i + 1 ] == '0' and s[ i + 2 ] == '0'; bool spol = s[ i ] == '1' and s[ i + 1 ] == '1' and s[ i + 2 ] == '1'; if( sam or spol ){ for(int pos = last; pos <= i; pos ++ ) near[ pos ] = i; last = i + 1; } } // cout << s << endl; // cout << n << endl; // FOR0(n) cout << near [ i ] << " "; // cout << endl; FOR0(n) if( near[ i ] >= 0) ans += n - near[ i ] - 2; cout << ans << endl; return 0; } |