// Język polski.cpp : Defines the entry point for the console application.
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool vowel(char a) {
if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y') return 1;
return 0;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string in;
cin >> in;
if (in.length() < 3) {
cout << 0 << endl;
return 0;
}
vector<bool> arr(in.length());
for (int i = 0; i < in.length(); i++) {
arr[i] = vowel(in[i]);
}
vector<int> breakpoints;
for (int i = 0; i < arr.size()-2; i++) {
if (arr[i] == arr[i + 1] && arr[i + 1] == arr[i + 2]) {
breakpoints.push_back(i);
}
}
reverse(breakpoints.begin(), breakpoints.end());
ll res = 0, s = arr.size();
for (ll i = 0; i < s - 2; i++) {
if (breakpoints.back() < i) breakpoints.pop_back();
if (breakpoints.size() == 0) break;
res += (s - breakpoints.back() - 2);
}
cout << res << 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 | // Język polski.cpp : Defines the entry point for the console application. // #include <bits/stdc++.h> using namespace std; typedef long long ll; bool vowel(char a) { if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y') return 1; return 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string in; cin >> in; if (in.length() < 3) { cout << 0 << endl; return 0; } vector<bool> arr(in.length()); for (int i = 0; i < in.length(); i++) { arr[i] = vowel(in[i]); } vector<int> breakpoints; for (int i = 0; i < arr.size()-2; i++) { if (arr[i] == arr[i + 1] && arr[i + 1] == arr[i + 2]) { breakpoints.push_back(i); } } reverse(breakpoints.begin(), breakpoints.end()); ll res = 0, s = arr.size(); for (ll i = 0; i < s - 2; i++) { if (breakpoints.back() < i) breakpoints.pop_back(); if (breakpoints.size() == 0) break; res += (s - breakpoints.back() - 2); } cout << res << endl; return 0; } |
English