#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;
const string samogloski = "aeiouy";
string input;
int samogl = 0, spolgl = 0;
void update_letter_counts(char c) {
if (samogloski.find(c) != string::npos) {
samogl++;
spolgl = 0;
} else {
spolgl++;
samogl = 0;
}
}
int main() {
ios::sync_with_stdio(false);
cin >> input;
int n = input.size();
long long count = 0;
long long previous = 0;
int last = 1; // last index with three hard letters
if (n < 3) {
cout << "0\n";
return 0;
}
update_letter_counts(input[0]);
update_letter_counts(input[1]);
for (int i = 2; i < input.size(); ++i) {
char c = input[i];
update_letter_counts(input[i]);
if (samogl >= 3 || spolgl >= 3) {
previous += i - last;
last = i;
}
count += previous;
}
cout << count << "\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 | #include <iostream> #include <vector> #include <string> #include <cstdio> using namespace std; const string samogloski = "aeiouy"; string input; int samogl = 0, spolgl = 0; void update_letter_counts(char c) { if (samogloski.find(c) != string::npos) { samogl++; spolgl = 0; } else { spolgl++; samogl = 0; } } int main() { ios::sync_with_stdio(false); cin >> input; int n = input.size(); long long count = 0; long long previous = 0; int last = 1; // last index with three hard letters if (n < 3) { cout << "0\n"; return 0; } update_letter_counts(input[0]); update_letter_counts(input[1]); for (int i = 2; i < input.size(); ++i) { char c = input[i]; update_letter_counts(input[i]); if (samogl >= 3 || spolgl >= 3) { previous += i - last; last = i; } count += previous; } cout << count << "\n"; return 0; } |
English