#include<bits/stdc++.h> #define N 200003 using namespace std; typedef long long LL; char in[N]; uint8_t t[N]; uint8_t let(char c) { if(c == 'o' || c == 'i' || c == 'a' || c == 'e' || c == 'u' || c == 'y') return 1; return 0; } int main() { scanf("%s", in); int n = strlen(in); for(int i = 0 ; i < n ; ++i) { t[i + 1] = let(in[i]); } int prev = 0; LL ans = 0; for(int i = 1 ; i <= n - 2; ++i) { if(t[i] == t[i + 1] && t[i] == t[i + 2]) { ans += (LL)(i - prev) * (LL)(n - i - 1); prev = i; } } printf("%lld\n", ans); }
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 | #include<bits/stdc++.h> #define N 200003 using namespace std; typedef long long LL; char in[N]; uint8_t t[N]; uint8_t let(char c) { if(c == 'o' || c == 'i' || c == 'a' || c == 'e' || c == 'u' || c == 'y') return 1; return 0; } int main() { scanf("%s", in); int n = strlen(in); for(int i = 0 ; i < n ; ++i) { t[i + 1] = let(in[i]); } int prev = 0; LL ans = 0; for(int i = 1 ; i <= n - 2; ++i) { if(t[i] == t[i + 1] && t[i] == t[i + 2]) { ans += (LL)(i - prev) * (LL)(n - i - 1); prev = i; } } printf("%lld\n", ans); } |