#include <bits/stdc++.h>
using namespace std;
string s;
int t[200005];
long long wynik;
int main()
{
ios::sync_with_stdio(false);
cin >> s;
for (int i=0; i<s.size(); i++)
{
if (s[i] == 'a')
{
t[i]='0';
}
else if (s[i] == 'e')
{
t[i]='0';
}
else if (s[i] == 'i')
{
t[i]='0';
}
else if (s[i] == 'o')
{
t[i]='0';
}
else if (s[i] == 'u')
{
t[i]='0';
}
else if (s[i] == 'y')
{
t[i]='0';
}
else
t[i]='1';
}
int last = -1, granica=-1, ile=0, n=s.size()-1;
for (int i=0; i<=n; i++)
{
if (last!=t[i])
{
last=t[i];
ile=1;
}
else if (last==t[i])
{
ile++;
if (ile>=3)
{
wynik += (i-2-granica) * (n-i+1);
//cout << i << endl;
granica=i-2;
}
}
}
cout << wynik;
}
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 62 | #include <bits/stdc++.h> using namespace std; string s; int t[200005]; long long wynik; int main() { ios::sync_with_stdio(false); cin >> s; for (int i=0; i<s.size(); i++) { if (s[i] == 'a') { t[i]='0'; } else if (s[i] == 'e') { t[i]='0'; } else if (s[i] == 'i') { t[i]='0'; } else if (s[i] == 'o') { t[i]='0'; } else if (s[i] == 'u') { t[i]='0'; } else if (s[i] == 'y') { t[i]='0'; } else t[i]='1'; } int last = -1, granica=-1, ile=0, n=s.size()-1; for (int i=0; i<=n; i++) { if (last!=t[i]) { last=t[i]; ile=1; } else if (last==t[i]) { ile++; if (ile>=3) { wynik += (i-2-granica) * (n-i+1); //cout << i << endl; granica=i-2; } } } cout << wynik; } |
English