#include <vector> #include <iostream> #include <string> using ll = long long; using namespace std; vector<char> spol = { 'a','e','y','u','o','i' }; int main() { ios::sync_with_stdio(0); ll n; string s; cin >> s; n = s.length(); vector<bool> letters(n); for (int i = 0; i < n; i++) { for (int j = 0; j < 6; j++) { if (s[i]==spol[j]) { letters[i] = true; break; } } } ll notWyn =0; ll count =2; for (int i = 0; i < n-2; i++) { if (letters[i]==letters[i+1] && letters[i+1]==letters[i+2]) { notWyn += (count) * (count + 1) / 2 -1; count = 1; } count++; } notWyn += (count) * (count + 1) / 2; ll wyn = (n*(n + 1) / 2); cout << wyn-notWyn; 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 44 45 46 | #include <vector> #include <iostream> #include <string> using ll = long long; using namespace std; vector<char> spol = { 'a','e','y','u','o','i' }; int main() { ios::sync_with_stdio(0); ll n; string s; cin >> s; n = s.length(); vector<bool> letters(n); for (int i = 0; i < n; i++) { for (int j = 0; j < 6; j++) { if (s[i]==spol[j]) { letters[i] = true; break; } } } ll notWyn =0; ll count =2; for (int i = 0; i < n-2; i++) { if (letters[i]==letters[i+1] && letters[i+1]==letters[i+2]) { notWyn += (count) * (count + 1) / 2 -1; count = 1; } count++; } notWyn += (count) * (count + 1) / 2; ll wyn = (n*(n + 1) / 2); cout << wyn-notWyn; return 0; } |