#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int,int>;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define rep(i,b,e) for(int i=(b); i<(e); i++)
#define each(a,x) for(auto& a : (x))
#define all(x) (x).begin(),(x).end()
#define sz(x) int((x).size())
#define endl "\n"
const long long inf = 2e17 + 10;
bool is_vowel( char c ){
string vowels = "aeiouy";
size_t pos = vowels.find_first_of(c,0);
return pos != string::npos;
}
void solve(){
string s;
cin >> s;
vector<bool>is_end( s.size()+1, false );
vector<int>next_end( s.size()+1, s.size() );
long long res = 0;
for( int i = 2; i < (int)s.size(); i++ ){
if( is_vowel(s[i-2]) && is_vowel(s[i-1]) && is_vowel(s[i]) )
is_end[i] = true;
if( !is_vowel(s[i-2]) && !is_vowel(s[i-1]) && !is_vowel(s[i]) )
is_end[i] = true;
}
for( int i = s.size()-1; i >= 0; i-- ){
next_end[i] = next_end[i+1];
if( is_end[i] )
next_end[i] = i;
}
for( int i = 0; i < (int)s.size()-2; i++ ){
res += s.size() - next_end[i+2];
}
cout << res << endl;
}
void clear(){
}
int main() {
cin.sync_with_stdio(0); cin.tie(0);
cout << fixed << setprecision(10);
int z = 1;
//cin >> z;
for(int i = 0; i < z; i++){
solve();
clear();
}
}
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 50 51 52 53 54 55 56 57 58 59 60 61 | #include <bits/stdc++.h> using namespace std; using ll = long long; using Vi = vector<int>; using Pii = pair<int,int>; #define x first #define y second #define pb push_back #define mp make_pair #define rep(i,b,e) for(int i=(b); i<(e); i++) #define each(a,x) for(auto& a : (x)) #define all(x) (x).begin(),(x).end() #define sz(x) int((x).size()) #define endl "\n" const long long inf = 2e17 + 10; bool is_vowel( char c ){ string vowels = "aeiouy"; size_t pos = vowels.find_first_of(c,0); return pos != string::npos; } void solve(){ string s; cin >> s; vector<bool>is_end( s.size()+1, false ); vector<int>next_end( s.size()+1, s.size() ); long long res = 0; for( int i = 2; i < (int)s.size(); i++ ){ if( is_vowel(s[i-2]) && is_vowel(s[i-1]) && is_vowel(s[i]) ) is_end[i] = true; if( !is_vowel(s[i-2]) && !is_vowel(s[i-1]) && !is_vowel(s[i]) ) is_end[i] = true; } for( int i = s.size()-1; i >= 0; i-- ){ next_end[i] = next_end[i+1]; if( is_end[i] ) next_end[i] = i; } for( int i = 0; i < (int)s.size()-2; i++ ){ res += s.size() - next_end[i+2]; } cout << res << endl; } void clear(){ } int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); int z = 1; //cin >> z; for(int i = 0; i < z; i++){ solve(); clear(); } } |
English