#include <bits/stdc++.h> using namespace std; #define REP(i, x) for( int i = 0; i < x; i++ ) #define FOR(i, x) for( int i = 1; i <=x; i++ ) #define LL long long string s; bool samogloska(char a){ if( a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y' ) return true; return false; } void process(string &s){ int siz = s.size(); REP(i, siz) s[i] = samogloska(s[i]); } LL wynik = 0; void find_rozw(){ LL last_trio = -1; LL len = s.size(); if( len < 3 ) return; REP(i, len-2){ if( s[i] == s[i+1] && s[i] == s[i+2] ){ wynik += - (last_trio - i) * (len - (i+2)); last_trio = i; } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> s; process(s); find_rozw(); cout << wynik << 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 | #include <bits/stdc++.h> using namespace std; #define REP(i, x) for( int i = 0; i < x; i++ ) #define FOR(i, x) for( int i = 1; i <=x; i++ ) #define LL long long string s; bool samogloska(char a){ if( a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y' ) return true; return false; } void process(string &s){ int siz = s.size(); REP(i, siz) s[i] = samogloska(s[i]); } LL wynik = 0; void find_rozw(){ LL last_trio = -1; LL len = s.size(); if( len < 3 ) return; REP(i, len-2){ if( s[i] == s[i+1] && s[i] == s[i+2] ){ wynik += - (last_trio - i) * (len - (i+2)); last_trio = i; } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> s; process(s); find_rozw(); cout << wynik << endl; return 0; } |