#include <cstdio> using namespace std; int is_vowel(char c) { char V[] = "aeiouy"; //samogloska int i; for (int i = 0; i < 6; i++) if (V[i] == c) return 1; return 0; } int main() { char s[200001]; long long i,c,C,R,D; scanf("%s",s); C = 0; i = 0; while (s[i++]) C++; i = 1; c = 1; D = 0; R = 0; while (s[i]) { if (is_vowel(s[i-1]) == is_vowel(s[i])) c++; else c = 1; if (c > 2) { R += (i-2+1-D)*(C-i-1+1); // printf("%c%c%c at %lld. %lld after. %lld total\n",s[i-2],s[i-1],s[i],i-2,C-i-1,(i-2+1)*(C-i-1+1)); // printf("%lld - %lld\n",(i-2+1-D)*(C-i-1+1),D); D = i-2+1; } i++; } 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 | #include <cstdio> using namespace std; int is_vowel(char c) { char V[] = "aeiouy"; //samogloska int i; for (int i = 0; i < 6; i++) if (V[i] == c) return 1; return 0; } int main() { char s[200001]; long long i,c,C,R,D; scanf("%s",s); C = 0; i = 0; while (s[i++]) C++; i = 1; c = 1; D = 0; R = 0; while (s[i]) { if (is_vowel(s[i-1]) == is_vowel(s[i])) c++; else c = 1; if (c > 2) { R += (i-2+1-D)*(C-i-1+1); // printf("%c%c%c at %lld. %lld after. %lld total\n",s[i-2],s[i-1],s[i],i-2,C-i-1,(i-2+1)*(C-i-1+1)); // printf("%lld - %lld\n",(i-2+1-D)*(C-i-1+1),D); D = i-2+1; } i++; } printf("%lld\n",R); return 0; } |