#include <bits/stdc++.h> using namespace std; const int N = 2e5; const char d[] = {'a', 'e', 'y', 'u', 'o', 'i'}; string slowo; long long res; int x, y; bool tab[N + 5]; void change(){ for(int i=0; i<slowo.size(); i++){ bool czy = false; for(int j=0; j<6; j++){ if(slowo[i] == d[j]){ czy = true; } } tab[i + 1] = czy; } } bool check(int id){ if(tab[id] == true and tab[id + 1] == true and tab[id + 2] == true){ return true; } if(tab[id] == false and tab[id + 1] == false and tab[id + 2] == false){ return true; } return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> slowo; change(); int sz = slowo.size(); // for(int i=1; i<=sz; i++){ // cout << tab[i] << " "; // } for(int i=1; i<=sz - 2; i++){ if(check(i)){ // cout << " jestem: " << i << "\n"; res ++; res += i - 1 - x; res += sz - 2 - i; res += (long long)(i - 1 - x) * (sz -2 - i); //blabla x = i; } } 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 | #include <bits/stdc++.h> using namespace std; const int N = 2e5; const char d[] = {'a', 'e', 'y', 'u', 'o', 'i'}; string slowo; long long res; int x, y; bool tab[N + 5]; void change(){ for(int i=0; i<slowo.size(); i++){ bool czy = false; for(int j=0; j<6; j++){ if(slowo[i] == d[j]){ czy = true; } } tab[i + 1] = czy; } } bool check(int id){ if(tab[id] == true and tab[id + 1] == true and tab[id + 2] == true){ return true; } if(tab[id] == false and tab[id + 1] == false and tab[id + 2] == false){ return true; } return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> slowo; change(); int sz = slowo.size(); // for(int i=1; i<=sz; i++){ // cout << tab[i] << " "; // } for(int i=1; i<=sz - 2; i++){ if(check(i)){ // cout << " jestem: " << i << "\n"; res ++; res += i - 1 - x; res += sz - 2 - i; res += (long long)(i - 1 - x) * (sz -2 - i); //blabla x = i; } } cout << res << "\n"; return 0; } |