#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 200*1000;
char t[MAXN+2];
char vowels[] = "aeiouy";
int main() {
cin >> t;
int n = strlen(t);
int v = 0, c = 0;
long long total = n; total *= (n + 1); total /= 2;
int last = 0;
for (int i = 0; i < n; i++) {
bool vowel = false;
for (int j = 0; vowels[j] != 0; j++) {
if (t[i] == vowels[j]) {
vowel = true; break;
}
}
if (vowel) {
v++; c = 0;
} else {
c++; v = 0;
}
last++;
if (v >= 3 || c >= 3) {
last = 2;
}
// cerr << last << endl;
total -= last;
}
cout << total << 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 32 33 34 35 36 37 38 39 40 | #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 200*1000; char t[MAXN+2]; char vowels[] = "aeiouy"; int main() { cin >> t; int n = strlen(t); int v = 0, c = 0; long long total = n; total *= (n + 1); total /= 2; int last = 0; for (int i = 0; i < n; i++) { bool vowel = false; for (int j = 0; vowels[j] != 0; j++) { if (t[i] == vowels[j]) { vowel = true; break; } } if (vowel) { v++; c = 0; } else { c++; v = 0; } last++; if (v >= 3 || c >= 3) { last = 2; } // cerr << last << endl; total -= last; } cout << total << endl; return 0; } |
English