#include <bits/stdc++.h>
using namespace std;
char samogloski[6] = {'a', 'e', 'i', 'o', 'u', 'y'};
bool czy_samogloska (char c) {
for (auto x : samogloski)
if(x == c)
return true;
return false;
}
bool czy_spolgloska (char c) {
return czy_samogloska(c) == false;
}
bool czy_kolejne_sa(string &s, int poz, int n) {
if (poz + 3 > n)
return false;
for (int i = poz; i < poz + 3; i++)
if(!czy_samogloska(s[i]))
return false;
return true;
}
bool czy_kolejne_sp(string &s, int poz, int n) {
if (poz + 3 > n)
return false;
for (int i = poz; i < poz + 3; i++)
if(!czy_spolgloska(s[i]))
return false;
return true;
}
int main() {
string s;
long long ans = 0;
int wyst_trzech = -1;
cin >> s;
for (int i = s.size() - 1; i >= 0; i--) {
if (czy_kolejne_sa(s, i, s.size()) || czy_kolejne_sp(s, i, s.size()))
wyst_trzech = i + 2;
if (wyst_trzech != -1)
ans += (long long)(s.size() - wyst_trzech);
}
cout << ans << "\n";
}
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 | #include <bits/stdc++.h> using namespace std; char samogloski[6] = {'a', 'e', 'i', 'o', 'u', 'y'}; bool czy_samogloska (char c) { for (auto x : samogloski) if(x == c) return true; return false; } bool czy_spolgloska (char c) { return czy_samogloska(c) == false; } bool czy_kolejne_sa(string &s, int poz, int n) { if (poz + 3 > n) return false; for (int i = poz; i < poz + 3; i++) if(!czy_samogloska(s[i])) return false; return true; } bool czy_kolejne_sp(string &s, int poz, int n) { if (poz + 3 > n) return false; for (int i = poz; i < poz + 3; i++) if(!czy_spolgloska(s[i])) return false; return true; } int main() { string s; long long ans = 0; int wyst_trzech = -1; cin >> s; for (int i = s.size() - 1; i >= 0; i--) { if (czy_kolejne_sa(s, i, s.size()) || czy_kolejne_sp(s, i, s.size())) wyst_trzech = i + 2; if (wyst_trzech != -1) ans += (long long)(s.size() - wyst_trzech); } cout << ans << "\n"; } |
English