#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); vector<char> vowels{ 'a','e','i','o','u','y' }; char c; bool lastWasVowel = false; int sameTypeSequence = 0; int lastHardSequencePos = -1; int pos = 0; long long int howManySubSequences = 0; while (cin >> c && c != '\n') { bool isVowel = find(vowels.begin(), vowels.end(), c) != vowels.end(); if (isVowel != lastWasVowel) { lastWasVowel = isVowel; sameTypeSequence = 1; } else ++sameTypeSequence; if (sameTypeSequence >= 3) lastHardSequencePos = pos - 2; howManySubSequences += lastHardSequencePos + 1; ++pos; } cout << howManySubSequences << "\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 | #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); vector<char> vowels{ 'a','e','i','o','u','y' }; char c; bool lastWasVowel = false; int sameTypeSequence = 0; int lastHardSequencePos = -1; int pos = 0; long long int howManySubSequences = 0; while (cin >> c && c != '\n') { bool isVowel = find(vowels.begin(), vowels.end(), c) != vowels.end(); if (isVowel != lastWasVowel) { lastWasVowel = isVowel; sameTypeSequence = 1; } else ++sameTypeSequence; if (sameTypeSequence >= 3) lastHardSequencePos = pos - 2; howManySubSequences += lastHardSequencePos + 1; ++pos; } cout << howManySubSequences << "\n"; return 0; } |