#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;
char t[N];
string s;
int tab[N], n, i, j, ind, akt;
LL res;
int main() {
scanf("%s", t);
s = t;
n = s.size();
for (i=0;i<n;i++) tab[i] = (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y');
res = 0;
ind = 0;
for (i=0;i<n;i++) {
if (ind < n && ind < i + 2) {
akt = 1;
j = i + 1;
while (j < n) {
if (tab[j] == tab[j - 1]) akt++; else akt = 1;
if (akt == 3) break;
j++;
}
ind = j;
}
res += (n - ind);
}
cout << res << endl;
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 | #include <bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef pair <int,int> ii; typedef pair <ii,int> iii; typedef long long LL; #define pb push_back const int INF = 2147483647; const int N = 200005; char t[N]; string s; int tab[N], n, i, j, ind, akt; LL res; int main() { scanf("%s", t); s = t; n = s.size(); for (i=0;i<n;i++) tab[i] = (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y'); res = 0; ind = 0; for (i=0;i<n;i++) { if (ind < n && ind < i + 2) { akt = 1; j = i + 1; while (j < n) { if (tab[j] == tab[j - 1]) akt++; else akt = 1; if (akt == 3) break; j++; } ind = j; } res += (n - ind); } cout << res << endl; return 0; } |
English