#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
ll res, n, ost;
string s;
bitset < maxn > b;
main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> s;
n = s.size();
for(int i=0; i<n; i++)
if(s[i] == 'e' || s[i] == 'y' || s[i] == 'u' || s[i] == 'i' || s[i] == 'o' || s[i] == 'a')
b[i] = 1;
for(int i=2; i<n; i++){
if((b[i] && b[i-1] && b[i-2]) || (!b[i] && !b[i-1] && !b[i-2]))
ost = i-1;
res += ost;
}
cout << res;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 5; ll res, n, ost; string s; bitset < maxn > b; main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin >> s; n = s.size(); for(int i=0; i<n; i++) if(s[i] == 'e' || s[i] == 'y' || s[i] == 'u' || s[i] == 'i' || s[i] == 'o' || s[i] == 'a') b[i] = 1; for(int i=2; i<n; i++){ if((b[i] && b[i-1] && b[i-2]) || (!b[i] && !b[i-1] && !b[i-2])) ost = i-1; res += ost; } cout << res; } |
English