// // main.cpp // pa_pol // // Created by Michał Kowalski on 10/12/2018. // Copyright © 2018 Michał Kowalski. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include <string.h> char W[200005]; int b = 0; long long count(int b, int e) { long long SUM = 0; int s = b; int B = b; while(s+2 < e) { if (W[s] == W[s+1] && W[s] == W[s+2]) { SUM += (long long)((s-B)+1)*(e-(s+2)); B = s+1; } ++s; } return SUM; } int main(int argc, const char * argv[]) { scanf("%s",W); int len = strlen(W); for (int i=0;i<len;++i) { if (W[i] == 'a' || W[i] == 'o' || W[i] == 'e' || W[i] == 'i' || W[i] == 'u' || W[i] == 'y' ) { W[i] = '0'; } else { W[i] = '1'; } } printf("%lld\n",count(0,len)); 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 | // // main.cpp // pa_pol // // Created by Michał Kowalski on 10/12/2018. // Copyright © 2018 Michał Kowalski. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include <string.h> char W[200005]; int b = 0; long long count(int b, int e) { long long SUM = 0; int s = b; int B = b; while(s+2 < e) { if (W[s] == W[s+1] && W[s] == W[s+2]) { SUM += (long long)((s-B)+1)*(e-(s+2)); B = s+1; } ++s; } return SUM; } int main(int argc, const char * argv[]) { scanf("%s",W); int len = strlen(W); for (int i=0;i<len;++i) { if (W[i] == 'a' || W[i] == 'o' || W[i] == 'e' || W[i] == 'i' || W[i] == 'u' || W[i] == 'y' ) { W[i] = '0'; } else { W[i] = '1'; } } printf("%lld\n",count(0,len)); return 0; } |