// Paweł Kubiak #include<cstdio> #include<cstring> typedef long long i64; char S[200005]; char t[256]; int main() { t['a'] = t['e'] = t['i'] = t['o'] = t['u'] = t['y'] = 1; scanf("%s", S); i64 len = strlen(S); i64 oks = 0, last = len; for(int i=len-1;i>=0;i--) { if(i+2 < len && t[S[i]] == t[S[i+1]] && t[S[i+1]] == t[S[i+2]]) last = i+2; oks += last - i; } printf("%lld\n", len*(len+1) / 2 - oks); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // Paweł Kubiak #include<cstdio> #include<cstring> typedef long long i64; char S[200005]; char t[256]; int main() { t['a'] = t['e'] = t['i'] = t['o'] = t['u'] = t['y'] = 1; scanf("%s", S); i64 len = strlen(S); i64 oks = 0, last = len; for(int i=len-1;i>=0;i--) { if(i+2 < len && t[S[i]] == t[S[i+1]] && t[S[i+1]] == t[S[i+2]]) last = i+2; oks += last - i; } printf("%lld\n", len*(len+1) / 2 - oks); return 0; } |