#include <iostream> #include <string> using namespace std; int a[200000 + 10]; int main() { ios_base::sync_with_stdio(0); // your code goes here int n, cnt=0; string s; cin >> s; n = s.length(); string vow = "aeuoiy"; for(int i=0; i<n;++i) { for (int j = 0; j < 6; ++j) { if (s[i] == vow[j]) { a[i] = 1; } } //cout << a[i] << "\n"; } int p = -1; long long res = 0; for (int i = 0; i < n; ++i) { if (p < i) { p = i; while (p + 2 < n && (a[p] != a[p+1] || a[p] != a[p+2])) { p++; } } res += max(0, n-p-2); //cout << "dod " << n - p - 2 << "\n"; } cout << res << "\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 | #include <iostream> #include <string> using namespace std; int a[200000 + 10]; int main() { ios_base::sync_with_stdio(0); // your code goes here int n, cnt=0; string s; cin >> s; n = s.length(); string vow = "aeuoiy"; for(int i=0; i<n;++i) { for (int j = 0; j < 6; ++j) { if (s[i] == vow[j]) { a[i] = 1; } } //cout << a[i] << "\n"; } int p = -1; long long res = 0; for (int i = 0; i < n; ++i) { if (p < i) { p = i; while (p + 2 < n && (a[p] != a[p+1] || a[p] != a[p+2])) { p++; } } res += max(0, n-p-2); //cout << "dod " << n - p - 2 << "\n"; } cout << res << "\n"; return 0; } |