#include <iostream>
#include <vector>
#define MAXN 200005
using namespace std;
int letter_type[256];
string input;
char letter;
long long first_pos_with_trio = (-1);
long long res = 0;
int main() {
vector<char> vowels = {'a', 'e', 'i', 'o', 'u', 'y'};
for(auto vowel : vowels) {
letter_type[vowel] = 1;
}
int current_type = -1;
int n_of_same_type = 0;
cin >> input;
for(int i = 0; i < input.size(); i++) {
letter = input[i];
if(letter_type[letter] != current_type) {
current_type = letter_type[letter];
n_of_same_type = 1;
}
else {
n_of_same_type++;
}
if(n_of_same_type >= 3) {
first_pos_with_trio = (i - 2);
}
if(first_pos_with_trio != (-1)) {
res += (first_pos_with_trio + 1);
}
}
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 42 43 44 45 46 47 | #include <iostream> #include <vector> #define MAXN 200005 using namespace std; int letter_type[256]; string input; char letter; long long first_pos_with_trio = (-1); long long res = 0; int main() { vector<char> vowels = {'a', 'e', 'i', 'o', 'u', 'y'}; for(auto vowel : vowels) { letter_type[vowel] = 1; } int current_type = -1; int n_of_same_type = 0; cin >> input; for(int i = 0; i < input.size(); i++) { letter = input[i]; if(letter_type[letter] != current_type) { current_type = letter_type[letter]; n_of_same_type = 1; } else { n_of_same_type++; } if(n_of_same_type >= 3) { first_pos_with_trio = (i - 2); } if(first_pos_with_trio != (-1)) { res += (first_pos_with_trio + 1); } } cout << res << endl; return 0; } |
English