#include <cstdio> #include <cstring> int c[26]; int main(){ char t[200000]; scanf("%s", t); int l=strlen(t), last=1; long long res=0; c[0] = c['e'-'a'] = c['i'-'a'] = c['o'-'a'] = c['u'-'a'] = c['y'-'a'] = 1; for (int i = 2; i < l; ++i){ if ((c[t[i]-'a'] == c[t[i-2]-'a']) && (c[t[i]-'a'] == c[t[i-1]-'a'])){ res += (i-last)*(l-i); last = i; } } printf("%lld\n", res); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <cstdio> #include <cstring> int c[26]; int main(){ char t[200000]; scanf("%s", t); int l=strlen(t), last=1; long long res=0; c[0] = c['e'-'a'] = c['i'-'a'] = c['o'-'a'] = c['u'-'a'] = c['y'-'a'] = 1; for (int i = 2; i < l; ++i){ if ((c[t[i]-'a'] == c[t[i-2]-'a']) && (c[t[i]-'a'] == c[t[i-1]-'a'])){ res += (i-last)*(l-i); last = i; } } printf("%lld\n", res); return 0; } |