#include <bits/stdc++.h> using namespace std; int main() { #ifndef DEBUG ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif bool isVowel[256] = {0}; char vowels[] = "aeiouy"; for(int i = 0; vowels[i]; i++) { isVowel[size_t(vowels[i])] = true; } int prevType = -1; int same = 0; int leftBound = 0; int64_t good = 0; int i = 0; for(int ch; isalpha(ch = cin.get()); i++) { int curType = isVowel[ch]; if(curType == prevType) { same++; } else { same = 1; prevType = curType; } if(same >= 3) { leftBound = i; } good += i + 1 - max(0, leftBound - 1); } int64_t total = i * int64_t(i + 1) / 2; cout << total - good << '\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 | #include <bits/stdc++.h> using namespace std; int main() { #ifndef DEBUG ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif bool isVowel[256] = {0}; char vowels[] = "aeiouy"; for(int i = 0; vowels[i]; i++) { isVowel[size_t(vowels[i])] = true; } int prevType = -1; int same = 0; int leftBound = 0; int64_t good = 0; int i = 0; for(int ch; isalpha(ch = cin.get()); i++) { int curType = isVowel[ch]; if(curType == prevType) { same++; } else { same = 1; prevType = curType; } if(same >= 3) { leftBound = i; } good += i + 1 - max(0, leftBound - 1); } int64_t total = i * int64_t(i + 1) / 2; cout << total - good << '\n'; return 0; } |