#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char tab[] = {'a', 'e', 'i', 'o', 'u', 'y'};
int main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
string s;
cin >> s;
pair <int, bool> x;
long long result = 0;
int last = 0;
for(int i = 0; i < 6; i++){
if(s[0] == tab[i]) x.second = true;
}
x.first = 1;
for(int i = 1; i < s.size(); i++){
bool przejscie = false;
for(int j = 0; j < 6; j++){
if(s[i] == tab[j]) przejscie = true;
}
if(przejscie){
if(x.second){
x.first++;
if(x.first >= 3){
last = i - 1;
}
} else {
x.first = 1;
x.second = !x.second;
}
} else {
if(!x.second){
x.first++;
if(x.first >= 3){
last = i - 1;
}
} else {
x.first = 1;
x.second = !x.second;
}
}
result += last;
//cerr << last << "\t" << x.first << "<--\n";
}
cout << result << "\n";
}
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 | #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; char tab[] = {'a', 'e', 'i', 'o', 'u', 'y'}; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); string s; cin >> s; pair <int, bool> x; long long result = 0; int last = 0; for(int i = 0; i < 6; i++){ if(s[0] == tab[i]) x.second = true; } x.first = 1; for(int i = 1; i < s.size(); i++){ bool przejscie = false; for(int j = 0; j < 6; j++){ if(s[i] == tab[j]) przejscie = true; } if(przejscie){ if(x.second){ x.first++; if(x.first >= 3){ last = i - 1; } } else { x.first = 1; x.second = !x.second; } } else { if(!x.second){ x.first++; if(x.first >= 3){ last = i - 1; } } else { x.first = 1; x.second = !x.second; } } result += last; //cerr << last << "\t" << x.first << "<--\n"; } cout << result << "\n"; } |
English