#include <bits/stdc++.h> #define SIZE(a) ((int)(a.size())) int main() { std::string s; std::cin >> s; std::vector<char> d {'a', 'e', 'i', 'o', 'u', 'y'}; std::vector<bool> t(1, 0); for(auto it : s) { bool set = false; for(auto jt : d) { if(it == jt) { t.push_back(true); set = true; break; } } if(!set) t.push_back(false); } // for(auto it : t) std::cout << it << "\n"; int e = 0; int f = 0; long long w = 0; for(int i = 1; i <= SIZE(t) - 2; i++) if(t[i] == t[i + 1] && t[i + 1] == t[i + 2]) { f = i + 1; w += e * (f - e - 1); e = i; } f = SIZE(t) - 1; w += e * (f - e - 1); std::cout << w << "\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 34 35 36 37 38 39 40 41 42 43 | #include <bits/stdc++.h> #define SIZE(a) ((int)(a.size())) int main() { std::string s; std::cin >> s; std::vector<char> d {'a', 'e', 'i', 'o', 'u', 'y'}; std::vector<bool> t(1, 0); for(auto it : s) { bool set = false; for(auto jt : d) { if(it == jt) { t.push_back(true); set = true; break; } } if(!set) t.push_back(false); } // for(auto it : t) std::cout << it << "\n"; int e = 0; int f = 0; long long w = 0; for(int i = 1; i <= SIZE(t) - 2; i++) if(t[i] == t[i + 1] && t[i + 1] == t[i + 2]) { f = i + 1; w += e * (f - e - 1); e = i; } f = SIZE(t) - 1; w += e * (f - e - 1); std::cout << w << "\n"; } |