#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
bool tab[N];
string str;
long long odp = 0;
bool samogloska(char c){
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y')
return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> str;
for(int i = 0; i < str.size(); i++){
if(i < 2) continue;
bool a = samogloska( str[i - 2] );
bool b = samogloska( str[i - 1] );
bool c = samogloska( str[i] );
if(a == b && b == c)
tab[i] = 1;
}
int q = 0;
for(int i = 0; i < str.size(); i++){
while(q < i + 2 || tab[q] == 0)
q++;
if(q < str.size())
odp += str.size() - q;
}
cout << odp << "\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 | #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; bool tab[N]; string str; long long odp = 0; bool samogloska(char c){ if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return 1; return 0; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> str; for(int i = 0; i < str.size(); i++){ if(i < 2) continue; bool a = samogloska( str[i - 2] ); bool b = samogloska( str[i - 1] ); bool c = samogloska( str[i] ); if(a == b && b == c) tab[i] = 1; } int q = 0; for(int i = 0; i < str.size(); i++){ while(q < i + 2 || tab[q] == 0) q++; if(q < str.size()) odp += str.size() - q; } cout << odp << "\n"; } |
English