#include<iostream>
#include<string>
#include<set>
#include<vector>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
set<char> vowels{'a','e','y','i','o','u'};
string s;
int c1,c2;
vector<long long> v;
long long res=0;
c1=c2=0;
cin >>s;
for(int i=0; i<s.size(); i++)
{
if(vowels.find(s[i])!=vowels.end())
{
c1++;
c2=0;
if(c1>=3)
{
v.push_back(i-1);
}
}
else
{
c2++;
c1=0;
if(c2>=3)
{
v.push_back(i-1);
}
}
}
v.push_back(s.size()-1);
for(int i=0; i < v.size()-1; i++)
{
res+=v[i]*(v[i+1]-v[i]);
}
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #include<iostream> #include<string> #include<set> #include<vector> using namespace std; int main() { ios_base::sync_with_stdio(false); set<char> vowels{'a','e','y','i','o','u'}; string s; int c1,c2; vector<long long> v; long long res=0; c1=c2=0; cin >>s; for(int i=0; i<s.size(); i++) { if(vowels.find(s[i])!=vowels.end()) { c1++; c2=0; if(c1>=3) { v.push_back(i-1); } } else { c2++; c1=0; if(c2>=3) { v.push_back(i-1); } } } v.push_back(s.size()-1); for(int i=0; i < v.size()-1; i++) { res+=v[i]*(v[i+1]-v[i]); } cout <<res<<endl; return 0; } |
English