#include "cstdio" #define S 200100 // #define D 1 #define lli long long int char a[S]; char *p, *pp; char c, cc; lli f[S]; lli *q, *qq; lli n, nn, r; int main() { scanf("%s", a); cc = 2; for(n=0, p=a, q=f; *p; ++p, ++n) { c = (*p == 'a' || *p == 'e' || *p == 'i' || *p == 'o' || *p == 'u' || *p == 'y') ? 1 : 0; #ifdef D printf("\t# i[%lld] = %c = %d\n", n, *p, c); #endif if(c != cc) { #ifdef D puts("\t# c != cc"); #endif cc = c; pp = p; } else { #ifdef D printf("\t# c == cc: %d\n", (int)(p - pp)); #endif if(p - pp > 1) { #ifdef D puts("\t# x3"); #endif *q = n - 1; ++q; } } } if(q==f) { puts("0"); return 0; } *q = n - 1; ++q; #ifdef D printf("\t# n=%lld; nn=%lld; |f|=%d\n", n, nn, (int)(q - f)); #endif r = ((n * (n + 1)) >> 1) - (n << 1) + 1; // r = ((n * (n + 1)) >> 1); #ifdef D printf("\t# r=%lld\n", r); #endif for(nn = 0, qq = f; qq < q; ++qq) { n = *qq - nn + 1; #ifdef D printf("\t# r=%lld [%lld = <%lld : %lld>]\n", r, n, nn, *qq); #endif if(n > 2) { r -= ((n * (n + 1)) >> 1) - (n << 1) + 1; // r -= ((n * (n + 1)) >> 1); } nn = *qq; } #ifdef D printf("\t# %s => %lld\n", a, r); #endif printf("%lld\n", r); 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #include "cstdio" #define S 200100 // #define D 1 #define lli long long int char a[S]; char *p, *pp; char c, cc; lli f[S]; lli *q, *qq; lli n, nn, r; int main() { scanf("%s", a); cc = 2; for(n=0, p=a, q=f; *p; ++p, ++n) { c = (*p == 'a' || *p == 'e' || *p == 'i' || *p == 'o' || *p == 'u' || *p == 'y') ? 1 : 0; #ifdef D printf("\t# i[%lld] = %c = %d\n", n, *p, c); #endif if(c != cc) { #ifdef D puts("\t# c != cc"); #endif cc = c; pp = p; } else { #ifdef D printf("\t# c == cc: %d\n", (int)(p - pp)); #endif if(p - pp > 1) { #ifdef D puts("\t# x3"); #endif *q = n - 1; ++q; } } } if(q==f) { puts("0"); return 0; } *q = n - 1; ++q; #ifdef D printf("\t# n=%lld; nn=%lld; |f|=%d\n", n, nn, (int)(q - f)); #endif r = ((n * (n + 1)) >> 1) - (n << 1) + 1; // r = ((n * (n + 1)) >> 1); #ifdef D printf("\t# r=%lld\n", r); #endif for(nn = 0, qq = f; qq < q; ++qq) { n = *qq - nn + 1; #ifdef D printf("\t# r=%lld [%lld = <%lld : %lld>]\n", r, n, nn, *qq); #endif if(n > 2) { r -= ((n * (n + 1)) >> 1) - (n << 1) + 1; // r -= ((n * (n + 1)) >> 1); } nn = *qq; } #ifdef D printf("\t# %s => %lld\n", a, r); #endif printf("%lld\n", r); return 0; } |