#include<bits/stdc++.h> using namespace std; using i64 = long long; using i32 = int; template<typename T> T load() { T x; cin >> x; return x; } template<typename T> vector<T> loadN(int s) { vector<T> vt(s); for(auto& el : vt) el = load<T>(); return vt; } template<typename T> ostream& operator<<(ostream& os, const vector<T>& vt) { for(auto& el : vt) os << el << ' '; return os; } bool isVowel[256]; i32 main() { ios::sync_with_stdio(false); for(auto c : "aiueyo") isVowel[(i32)c] = true; auto word = load<string>(); auto size = (i32) word.size(); auto isBanned = [&](i32 pos) { return isVowel[word[pos]] == isVowel[word[pos - 1]] && isVowel[word[pos - 1]] == isVowel[word[pos - 2]]; }; i64 bannedCounter = 0; auto lastBanned = 1; for(i32 i = 2 ; i < size ; ++i) { if(isBanned(i)) { bannedCounter += static_cast<i64>(size - i) * (i - lastBanned); lastBanned = i; } } cout << bannedCounter << '\n'; }
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 | #include<bits/stdc++.h> using namespace std; using i64 = long long; using i32 = int; template<typename T> T load() { T x; cin >> x; return x; } template<typename T> vector<T> loadN(int s) { vector<T> vt(s); for(auto& el : vt) el = load<T>(); return vt; } template<typename T> ostream& operator<<(ostream& os, const vector<T>& vt) { for(auto& el : vt) os << el << ' '; return os; } bool isVowel[256]; i32 main() { ios::sync_with_stdio(false); for(auto c : "aiueyo") isVowel[(i32)c] = true; auto word = load<string>(); auto size = (i32) word.size(); auto isBanned = [&](i32 pos) { return isVowel[word[pos]] == isVowel[word[pos - 1]] && isVowel[word[pos - 1]] == isVowel[word[pos - 2]]; }; i64 bannedCounter = 0; auto lastBanned = 1; for(i32 i = 2 ; i < size ; ++i) { if(isBanned(i)) { bannedCounter += static_cast<i64>(size - i) * (i - lastBanned); lastBanned = i; } } cout << bannedCounter << '\n'; } |