#include <iostream>
#include <iterator>
#include <list>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
// #define DEBUG
#define isVowel(c) (vowels.find(c) != string::npos)
const string vowels = "aeiouy";
#define size_tv vector<size_t>
int main() {
string characters;
cin >> characters;
#ifdef DEBUG
cout << characters << endl;
#endif
auto size = characters.size();
size_t total = 0;
for (size_t i = 0; i < size; i++)
for (size_t j = i; j < size; j++) {
string part = characters.substr(i, j - i + 1);
char chr = part[0];
size_t counter = 1;
bool vowelNew = isVowel(chr);
bool vowelOld = vowelNew;
#ifdef DEBUG
cout << part;
#endif
for (size_t k = 1; k < part.size(); k++) {
chr = part[k];
vowelNew = isVowel(chr);
if (vowelOld != vowelNew) {
vowelOld = vowelNew;
counter = 0;
}
counter++;
if (counter >= 3) {
#ifdef DEBUG
cout << "\tOK";
#endif
total += size - j;
j = size;
break;
}
}
#ifdef DEBUG
cout << endl;
#endif
}
cout << total << 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #include <iostream> #include <iterator> #include <list> #include <numeric> #include <string> #include <vector> using namespace std; // #define DEBUG #define isVowel(c) (vowels.find(c) != string::npos) const string vowels = "aeiouy"; #define size_tv vector<size_t> int main() { string characters; cin >> characters; #ifdef DEBUG cout << characters << endl; #endif auto size = characters.size(); size_t total = 0; for (size_t i = 0; i < size; i++) for (size_t j = i; j < size; j++) { string part = characters.substr(i, j - i + 1); char chr = part[0]; size_t counter = 1; bool vowelNew = isVowel(chr); bool vowelOld = vowelNew; #ifdef DEBUG cout << part; #endif for (size_t k = 1; k < part.size(); k++) { chr = part[k]; vowelNew = isVowel(chr); if (vowelOld != vowelNew) { vowelOld = vowelNew; counter = 0; } counter++; if (counter >= 3) { #ifdef DEBUG cout << "\tOK"; #endif total += size - j; j = size; break; } } #ifdef DEBUG cout << endl; #endif } cout << total << endl; return 0; } |
English