#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
iostream::sync_with_stdio(0);
cin.tie(0);
vector<char>vowel = { 'a', 'e', 'i', 'o', 'u', 'y' };
string a;
cin >> a;
vector<bool>type(a.length());
vector<int>clusterEnd;
for (unsigned i = 0; i < a.length(); ++i)
{
type[i] = 0;
for (auto j : vowel)
{
if (a[i] == j)
{
type[i] = 1;
break;
}
}
if (i >= 2 and type[i - 1] == type[i] and type[i - 2] == type[i])
clusterEnd.push_back(i);
}
long long result = 0;
for (unsigned i = 0, pos = 0; pos < clusterEnd.size(); ++i)
{
result += a.length() - clusterEnd[pos];
if (clusterEnd[pos] == i + 2)
++pos;
}
cout << result;
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 | #include<iostream> #include<string> #include<vector> using namespace std; int main() { iostream::sync_with_stdio(0); cin.tie(0); vector<char>vowel = { 'a', 'e', 'i', 'o', 'u', 'y' }; string a; cin >> a; vector<bool>type(a.length()); vector<int>clusterEnd; for (unsigned i = 0; i < a.length(); ++i) { type[i] = 0; for (auto j : vowel) { if (a[i] == j) { type[i] = 1; break; } } if (i >= 2 and type[i - 1] == type[i] and type[i - 2] == type[i]) clusterEnd.push_back(i); } long long result = 0; for (unsigned i = 0, pos = 0; pos < clusterEnd.size(); ++i) { result += a.length() - clusterEnd[pos]; if (clusterEnd[pos] == i + 2) ++pos; } cout << result; return 0; } |
English