#include <bits/stdc++.h> #define F first #define S second #define ll long long #define ld long double #define vi vector < int > #define vll vector < ll > #define pb push_back #define sz(x) int((x).size()) #define pii pair < int, int > #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define vpii vector < pii > #define sqr(x) ((x)*(x)) #define fenwick(x) ((x) & -(x)) #define debug(x) cout << "[ " << #x << " ]: " << x << "\n"; using namespace std; //CZY DANE POSORTOWANE, N = 0, N = 1, CZYTANIE TRESCI, < rosnaco, > malejaco bool sa(char s) { if (s == 'i' || s == 'a' || s == 'e' || s == 'o' || s == 'u' || s == 'y')return true; return false; } bool sp(char s) { if (!sa(s))return 1; return 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; int ost = 0; ll wynik = 0; for (int i = 0; i < sz(s) - 2; ++i) { if (sa(s[i]) && sa(s[i + 1]) && sa(s[i + 2])) { wynik += ((i - ost + 1) * (sz(s) - i - 2)); ost = i + 1; } if (sp(s[i]) && sp(s[i + 1]) && sp(s[i + 2])) { wynik += ((i - ost + 1) * (sz(s) - i - 2)); ost = i + 1; } } cout << wynik << "\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 60 61 62 63 | #include <bits/stdc++.h> #define F first #define S second #define ll long long #define ld long double #define vi vector < int > #define vll vector < ll > #define pb push_back #define sz(x) int((x).size()) #define pii pair < int, int > #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define vpii vector < pii > #define sqr(x) ((x)*(x)) #define fenwick(x) ((x) & -(x)) #define debug(x) cout << "[ " << #x << " ]: " << x << "\n"; using namespace std; //CZY DANE POSORTOWANE, N = 0, N = 1, CZYTANIE TRESCI, < rosnaco, > malejaco bool sa(char s) { if (s == 'i' || s == 'a' || s == 'e' || s == 'o' || s == 'u' || s == 'y')return true; return false; } bool sp(char s) { if (!sa(s))return 1; return 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; int ost = 0; ll wynik = 0; for (int i = 0; i < sz(s) - 2; ++i) { if (sa(s[i]) && sa(s[i + 1]) && sa(s[i + 2])) { wynik += ((i - ost + 1) * (sz(s) - i - 2)); ost = i + 1; } if (sp(s[i]) && sp(s[i + 1]) && sp(s[i + 2])) { wynik += ((i - ost + 1) * (sz(s) - i - 2)); ost = i + 1; } } cout << wynik << "\n"; return 0; } |