#include <bits/stdc++.h>
using namespace std;
string x, act;
set <int> A = {'a', 'e', 'i', 'o', 'u', 'y'};
long long ans, n, kon;
bool ok(int poc, int kon){
if (kon - poc + 1 < 3) return true;
if (A.count(x[kon]) and A.count(x[kon - 1]) and A.count(x[kon - 2]))
return false;
if (!A.count(x[kon]) and !A.count(x[kon - 1]) and !A.count(x[kon - 2]))
return false;
return true;
}
int main(){
cin >> x;
kon = 0;
n = x.length();
for (int poc = 0; poc < n; poc ++){
while (kon < n - 1 and ok(poc, kon + 1)) kon ++;
ans += (kon - poc + 1);
// cout << poc << " " << kon << endl;
}
cout << (n + 1) * n / 2 - ans;
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 | #include <bits/stdc++.h> using namespace std; string x, act; set <int> A = {'a', 'e', 'i', 'o', 'u', 'y'}; long long ans, n, kon; bool ok(int poc, int kon){ if (kon - poc + 1 < 3) return true; if (A.count(x[kon]) and A.count(x[kon - 1]) and A.count(x[kon - 2])) return false; if (!A.count(x[kon]) and !A.count(x[kon - 1]) and !A.count(x[kon - 2])) return false; return true; } int main(){ cin >> x; kon = 0; n = x.length(); for (int poc = 0; poc < n; poc ++){ while (kon < n - 1 and ok(poc, kon + 1)) kon ++; ans += (kon - poc + 1); // cout << poc << " " << kon << endl; } cout << (n + 1) * n / 2 - ans; return 0; } |
English