#include <cstdio> #include <cstring> #define scanf(...) scanf(__VA_ARGS__)?:0 int n,js['z'+1],b[200005],zak; char s[200005]; long long wynik; int main() { js['a']=js['e']=js['i']=js['o']=js['u']=js['y']=1; scanf("%s",s); n=strlen(s); wynik=(long long)n*(n+1)/2; for (int i=n-1; i>=0; i--) { if (js[s[i]]==js[s[i-1]] && js[s[i-1]]==js[s[i-2]]) b[i]=1; if (i>=n-2) zak=n; else if (b[i+2]) zak=i+2; wynik-=zak-i; } printf("%lld\n",wynik); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <cstdio> #include <cstring> #define scanf(...) scanf(__VA_ARGS__)?:0 int n,js['z'+1],b[200005],zak; char s[200005]; long long wynik; int main() { js['a']=js['e']=js['i']=js['o']=js['u']=js['y']=1; scanf("%s",s); n=strlen(s); wynik=(long long)n*(n+1)/2; for (int i=n-1; i>=0; i--) { if (js[s[i]]==js[s[i-1]] && js[s[i-1]]==js[s[i-2]]) b[i]=1; if (i>=n-2) zak=n; else if (b[i+2]) zak=i+2; wynik-=zak-i; } printf("%lld\n",wynik); } |