#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX_WORD 200000
using namespace std;
bool is_samogloska(char l) {
if ((l == 'a') || (l == 'e') || (l == 'y') || (l == 'u')|| (l == 'i')|| (l == 'o'))
return true;
return false;
}
int main(int argc, char const *argv[]) {
string word;
getline(cin, word);
int word_size = word.length();
vector<int> starts;
vector<int> ends;
bool was_sam = false;
int segment_len = 0;
bool is_sam = false;
int start_index;
int end_index = 0;
bool added = false;
for (int i = 0; i < word_size; ++i) {
if (i == 0) {
start_index = 0;
if (is_samogloska(word.at(i))) {
was_sam = true;
} else {
was_sam = false;
}
segment_len++;
} else {
added = false;
is_sam = is_samogloska(word.at(i));
if (was_sam && is_sam) {
added = true;
} else if (!was_sam && !is_sam) {
added = true;
}
if (added) {
segment_len++;
end_index = i;
} else {
end_index = i - 1;
}
if (end_index - start_index >= 2) {
starts.push_back(start_index);
ends.push_back(end_index);
start_index += 1;
}
was_sam = is_sam;
if (!added) {
start_index = i;
segment_len = 0;
end_index = i;
}
}
}
long counter = 0;
long start = 0;
long end = 0;
long prev = -1;
long left = 0;
long right = 0;
for (int i = 0; i < starts.size(); ++i) {
start = starts[i];
if (prev == -1) {
left = start;
} else {
left = start - prev - 1;
}
right = word.size() - start - 3;
counter += (left + 1) * (right + 1);
prev = start;
}
cout << counter << "\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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include <cstdio> #include <iostream> #include <vector> #include <algorithm> #define MAX_WORD 200000 using namespace std; bool is_samogloska(char l) { if ((l == 'a') || (l == 'e') || (l == 'y') || (l == 'u')|| (l == 'i')|| (l == 'o')) return true; return false; } int main(int argc, char const *argv[]) { string word; getline(cin, word); int word_size = word.length(); vector<int> starts; vector<int> ends; bool was_sam = false; int segment_len = 0; bool is_sam = false; int start_index; int end_index = 0; bool added = false; for (int i = 0; i < word_size; ++i) { if (i == 0) { start_index = 0; if (is_samogloska(word.at(i))) { was_sam = true; } else { was_sam = false; } segment_len++; } else { added = false; is_sam = is_samogloska(word.at(i)); if (was_sam && is_sam) { added = true; } else if (!was_sam && !is_sam) { added = true; } if (added) { segment_len++; end_index = i; } else { end_index = i - 1; } if (end_index - start_index >= 2) { starts.push_back(start_index); ends.push_back(end_index); start_index += 1; } was_sam = is_sam; if (!added) { start_index = i; segment_len = 0; end_index = i; } } } long counter = 0; long start = 0; long end = 0; long prev = -1; long left = 0; long right = 0; for (int i = 0; i < starts.size(); ++i) { start = starts[i]; if (prev == -1) { left = start; } else { left = start - prev - 1; } right = word.size() - start - 3; counter += (left + 1) * (right + 1); prev = start; } cout << counter << "\n"; return 0; } |
English