#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> using namespace std; bool isVowel(char c) { return c == 'a' || c == 'e' || c == 'i' ||c == 'o' || c == 'u' || c == 'y'; } int main() { string s; cin >> s; int n = s.length(); if (n < 3) { cout << 0 << endl; return 0; } long long res = 0; int npl = -1; for(int i=2;i<n;i++) { if (isVowel(s[i]) == isVowel(s[i-1]) && isVowel(s[i])== isVowel(s[i-2])) { npl = i; } res += (npl == -1) ? 0 : (npl - 1); } cout << res << endl; 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 | #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> using namespace std; bool isVowel(char c) { return c == 'a' || c == 'e' || c == 'i' ||c == 'o' || c == 'u' || c == 'y'; } int main() { string s; cin >> s; int n = s.length(); if (n < 3) { cout << 0 << endl; return 0; } long long res = 0; int npl = -1; for(int i=2;i<n;i++) { if (isVowel(s[i]) == isVowel(s[i-1]) && isVowel(s[i])== isVowel(s[i-2])) { npl = i; } res += (npl == -1) ? 0 : (npl - 1); } cout << res << endl; return 0; } |