#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
unordered_set<int> t({'a', 'e', 'i', 'o', 'u', 'y'});
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
int index = -1;
int licz = 1;
bool ost = (t.find(s[0]) != t.end());
LL result = 0;
for(int i = 1; i < s.size(); i++)
{
bool exists = (t.find(s[i]) != t.end());
if(exists == ost)
licz++;
else
licz = 1;
ost=exists;
if(licz >= 3)
index = i - 2;
result += LL(index + 1);
}
cout << result;
}
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 | #include <bits/stdc++.h> using namespace std; typedef long long LL; unordered_set<int> t({'a', 'e', 'i', 'o', 'u', 'y'}); int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int index = -1; int licz = 1; bool ost = (t.find(s[0]) != t.end()); LL result = 0; for(int i = 1; i < s.size(); i++) { bool exists = (t.find(s[i]) != t.end()); if(exists == ost) licz++; else licz = 1; ost=exists; if(licz >= 3) index = i - 2; result += LL(index + 1); } cout << result; } |
English