#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void initialize()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
bool isvowel(char a) { return (a == 'a' or a == 'e' or a == 'i' or a == 'o' or a == 'u' or a == 'y'); }
int main()
{
initialize();
string s;
cin >> s;
int n = s.length();
LL answer = 0;
int last_length = 1, end = 0;
for (auto i = 0; i < n; i++)
{
last_length = min(last_length, end - i + 1);
while (end < n and last_length < 3)
{
end++;
if (end == n)
break;
if (isvowel(s[end]) == isvowel(s[end - 1]))
last_length++;
else
last_length = 1;
}
answer += n - end;
}
cout << answer << '\n';
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 | #include <bits/stdc++.h> using namespace std; using LL = long long; void initialize() { ios::sync_with_stdio(false); cin.tie(nullptr); } bool isvowel(char a) { return (a == 'a' or a == 'e' or a == 'i' or a == 'o' or a == 'u' or a == 'y'); } int main() { initialize(); string s; cin >> s; int n = s.length(); LL answer = 0; int last_length = 1, end = 0; for (auto i = 0; i < n; i++) { last_length = min(last_length, end - i + 1); while (end < n and last_length < 3) { end++; if (end == n) break; if (isvowel(s[end]) == isvowel(s[end - 1])) last_length++; else last_length = 1; } answer += n - end; } cout << answer << '\n'; return 0; } |
English