#include "stdio.h" #include "string.h" #define MAX 200000 char t[MAX]; int n; int isvowel(char c) { switch(c) { case 'i': case 'e': case 'u': case 'a': case 'o': case 'y': return 1; } return 0; } int main(void) { scanf("%s", t); n = strlen(t); long long int found = 0; int inrow = 1; int lastend = 0; for (int i = 1; i < n; i++) { if (isvowel(t[i]) == isvowel(t[i-1])) { inrow++; if (inrow > 2) { found += (long long int)(i-1-lastend)*(long long int)(n-i); lastend = i-1; } } else { inrow = 1; } } printf("%d\n", found); 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 | #include "stdio.h" #include "string.h" #define MAX 200000 char t[MAX]; int n; int isvowel(char c) { switch(c) { case 'i': case 'e': case 'u': case 'a': case 'o': case 'y': return 1; } return 0; } int main(void) { scanf("%s", t); n = strlen(t); long long int found = 0; int inrow = 1; int lastend = 0; for (int i = 1; i < n; i++) { if (isvowel(t[i]) == isvowel(t[i-1])) { inrow++; if (inrow > 2) { found += (long long int)(i-1-lastend)*(long long int)(n-i); lastend = i-1; } } else { inrow = 1; } } printf("%d\n", found); return 0; } |