//Zadanie "Jezyk Polski", autor rozwiazania: Pawel Talar #include <bits/stdc++.h> using namespace std; bool is_vowel(char a) { if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y') return true; return false; } int main() { std::ios::sync_with_stdio(false); string s; cin >> s; int size = s.size(); if(size < 3) { cout << 0 << "\n"; return 0; } long long res = 0; long long m = 0; int prev = 0; for(int i = 0; i < size-2; i++) { bool k = is_vowel(s[i]); if(is_vowel(s[i+1]) == k && is_vowel(s[i+2]) == k) { long long a = res; res += (long long)((long long)((long long)(i+1) - (long long)prev) * (long long)((long long)size - (long long)(i+2))); m = max(m, res); prev = i+1; } } 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 | //Zadanie "Jezyk Polski", autor rozwiazania: Pawel Talar #include <bits/stdc++.h> using namespace std; bool is_vowel(char a) { if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y') return true; return false; } int main() { std::ios::sync_with_stdio(false); string s; cin >> s; int size = s.size(); if(size < 3) { cout << 0 << "\n"; return 0; } long long res = 0; long long m = 0; int prev = 0; for(int i = 0; i < size-2; i++) { bool k = is_vowel(s[i]); if(is_vowel(s[i+1]) == k && is_vowel(s[i+2]) == k) { long long a = res; res += (long long)((long long)((long long)(i+1) - (long long)prev) * (long long)((long long)size - (long long)(i+2))); m = max(m, res); prev = i+1; } } cout << res << "\n"; return 0; } |