#include<algorithm> #include<cstdio> #include<iostream> #include<vector> using namespace std; long long pre[200002] = {1}; vector<int> pocz, kon; bool samogloska(char z){ return z =='a' || z == 'e' || z == 'i' || z =='u' || z =='y' || z =='o'; } int main() { ios_base::sync_with_stdio(0); string s; int i, j, k = 0, p; bool sam = false; long long wyn = 0; cin >> s; if(samogloska(s[0])) sam = true; for(i = 0; i < s.size(); ++i) { if(samogloska(s[i])) { if(sam) pre[i] = pre[i-1] + 1; else pre[i] = 1; sam = true; } else { if(sam) pre[i] = 1; else pre[i] = pre[i-1] + 1; sam = false; } } //for(i = 0; i < pocz.size(); ++i) cout <<pocz[i] <<" " <<kon[i] << endl; for(p = 0; p < s.size() ; ++p) { while(k < s.size() && k < p + 2 ) k++; while(k < s.size() && pre[k] < 3) k++; if(k == s.size()) break; wyn += s.size() - k; } 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 42 43 44 45 | #include<algorithm> #include<cstdio> #include<iostream> #include<vector> using namespace std; long long pre[200002] = {1}; vector<int> pocz, kon; bool samogloska(char z){ return z =='a' || z == 'e' || z == 'i' || z =='u' || z =='y' || z =='o'; } int main() { ios_base::sync_with_stdio(0); string s; int i, j, k = 0, p; bool sam = false; long long wyn = 0; cin >> s; if(samogloska(s[0])) sam = true; for(i = 0; i < s.size(); ++i) { if(samogloska(s[i])) { if(sam) pre[i] = pre[i-1] + 1; else pre[i] = 1; sam = true; } else { if(sam) pre[i] = 1; else pre[i] = pre[i-1] + 1; sam = false; } } //for(i = 0; i < pocz.size(); ++i) cout <<pocz[i] <<" " <<kon[i] << endl; for(p = 0; p < s.size() ; ++p) { while(k < s.size() && k < p + 2 ) k++; while(k < s.size() && pre[k] < 3) k++; if(k == s.size()) break; wyn += s.size() - k; } cout << wyn; return 0; } |