#include<bits/stdc++.h> #define ll long long #define pb push_back #define MP make_pair using namespace std; const int M = 2e5 + 2317; ll before[M]; bool sam(char l){ return l == 'a' || l == 'e' || l == 'i' ||l == 'o' || l == 'u' || l == 'y'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; for(int i = 0; i < s.size() + 2; i++) before[i] = -1; if(s.size() < 3){ cout << "0"; return 0; } ll wyn = 0; for(int i = 0; i < s.size(); i++){ if(i + 2 < s.size()){ int ile = sam(s[i]) + sam(s[i + 1]) + sam(s[i + 2]); if(ile % 3 == 0) before[i + 2] = i; } if(i != 0) before[i] = max(before[i], before[i - 1]); wyn += before[i] + 1; } cout << wyn; 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include<bits/stdc++.h> #define ll long long #define pb push_back #define MP make_pair using namespace std; const int M = 2e5 + 2317; ll before[M]; bool sam(char l){ return l == 'a' || l == 'e' || l == 'i' ||l == 'o' || l == 'u' || l == 'y'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; for(int i = 0; i < s.size() + 2; i++) before[i] = -1; if(s.size() < 3){ cout << "0"; return 0; } ll wyn = 0; for(int i = 0; i < s.size(); i++){ if(i + 2 < s.size()){ int ile = sam(s[i]) + sam(s[i + 1]) + sam(s[i + 2]); if(ile % 3 == 0) before[i + 2] = i; } if(i != 0) before[i] = max(before[i], before[i - 1]); wyn += before[i] + 1; } cout << wyn; return 0; } |