#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> char input[200000 + 2]; bool vowel(char c) { return (c == 'a' || c == 'e' || c == 'y' || c == 'o' || c == 'u' || c == 'i'); } int main() { scanf("%s", input); const int length = strlen(input); long long output = 0; int last = -1; for (int i = 0; i < length; i++) { if (i - 2 >= 0) { const bool vowel2 = vowel(input[i - 2]); const bool vowel1 = vowel(input[i - 1]); const bool vowel0 = vowel(input[i - 0]); if (vowel2 == vowel1 && vowel1 == vowel0) { last = i - 2; } } if (last != -1) { output += last + 1; } } printf("%lld\n", output); 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 | #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> char input[200000 + 2]; bool vowel(char c) { return (c == 'a' || c == 'e' || c == 'y' || c == 'o' || c == 'u' || c == 'i'); } int main() { scanf("%s", input); const int length = strlen(input); long long output = 0; int last = -1; for (int i = 0; i < length; i++) { if (i - 2 >= 0) { const bool vowel2 = vowel(input[i - 2]); const bool vowel1 = vowel(input[i - 1]); const bool vowel0 = vowel(input[i - 0]); if (vowel2 == vowel1 && vowel1 == vowel0) { last = i - 2; } } if (last != -1) { output += last + 1; } } printf("%lld\n", output); return 0; } |