#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
int main(){
set<char> vowels = {'a', 'e', 'i', 'o', 'u', 'y'};
string expose;
cin >> expose;
ll count = 0;
ll type = -1;
ll result = 0;
ll lastPos = 1;
for(int i=0; i < expose.size(); ++i){
char c = expose[i];
int newType = (vowels.count(c));
if(newType == type){
count++;
}else{
count=1;
}
type = newType;
if(count >= 3){
ll a = (i - 3) - (lastPos - 2) + 1;
ll b = expose.size() - i -1 +1;
result+= a * b;
lastPos = i;
}
}
cout << result << 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 41 42 43 44 45 | #include <iostream> #include <algorithm> #include <vector> #include <set> using namespace std; typedef long long ll; int main(){ set<char> vowels = {'a', 'e', 'i', 'o', 'u', 'y'}; string expose; cin >> expose; ll count = 0; ll type = -1; ll result = 0; ll lastPos = 1; for(int i=0; i < expose.size(); ++i){ char c = expose[i]; int newType = (vowels.count(c)); if(newType == type){ count++; }else{ count=1; } type = newType; if(count >= 3){ ll a = (i - 3) - (lastPos - 2) + 1; ll b = expose.size() - i -1 +1; result+= a * b; lastPos = i; } } cout << result << endl; return 0; } |
English