#include <cmath> #include <map> #include <string> #include <vector> #include <algorithm> #include <iostream> #include <cmath> #include <iomanip> #include <set> #include <unordered_set> #define M_PI 3.14159265358979323846 #define ull unsigned long long #define ll long long #define ld long double #define pii pair<int,int> #define pll pair<long long, long long> #define vi vector<int> #define vb vector<bool> #define vll vector<long long> #define vull vector<unsigned long long> #define vii vector<pair<int,int>> #define vvi vector<vector<int>> using namespace std; bool sam(char c) { if (c == 'a') return true; if (c == 'e') return true; if (c == 'i') return true; if (c == 'o') return true; if (c == 'u') return true; if (c == 'y') return true; return false; } int main() { ios_base::sync_with_stdio(0); string s; int last_start = -1; ull all = 0; cin >> s; if (s.size() < 3) { cout << all; return 0; } int n = s.size(); for (int i = 0; i < n - 2; ++i) { if (sam(s[i]) && sam(s[i + 1]) && sam(s[i + 2]) || !sam(s[i]) && !sam(s[i + 1]) && !sam(s[i + 2])) { all += 1ll * (i - last_start) * (n - (i + 2)); last_start = i; } } cout << all; }
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 | #include <cmath> #include <map> #include <string> #include <vector> #include <algorithm> #include <iostream> #include <cmath> #include <iomanip> #include <set> #include <unordered_set> #define M_PI 3.14159265358979323846 #define ull unsigned long long #define ll long long #define ld long double #define pii pair<int,int> #define pll pair<long long, long long> #define vi vector<int> #define vb vector<bool> #define vll vector<long long> #define vull vector<unsigned long long> #define vii vector<pair<int,int>> #define vvi vector<vector<int>> using namespace std; bool sam(char c) { if (c == 'a') return true; if (c == 'e') return true; if (c == 'i') return true; if (c == 'o') return true; if (c == 'u') return true; if (c == 'y') return true; return false; } int main() { ios_base::sync_with_stdio(0); string s; int last_start = -1; ull all = 0; cin >> s; if (s.size() < 3) { cout << all; return 0; } int n = s.size(); for (int i = 0; i < n - 2; ++i) { if (sam(s[i]) && sam(s[i + 1]) && sam(s[i + 2]) || !sam(s[i]) && !sam(s[i + 1]) && !sam(s[i + 2])) { all += 1ll * (i - last_start) * (n - (i + 2)); last_start = i; } } cout << all; } |