#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
char s[maxn];
int n, x, y, c;
long long odp;
vector<int> v;
int main(){
scanf("%s", s+1);
n=strlen(s+1);
for(int i=1; i<=n; i++){
char h=s[i];
if(h=='a' || h=='e' || h=='o' || h=='i' || h=='u' || h=='y'){
x++;
y=0;
}
else{
y++;
x=0;
}
if(x==3 || y==3){
v.push_back(i);
if(x==3) x=2;
if(y==3) y=2;
}
}
for(int i=1; i<=n; i++){
while(c<v.size() && v[c]<i+2) c++;
if(c>=v.size()) break;
odp+=n-v[c]+1;
}
printf("%lld\n", odp);
}
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 | #include<bits/stdc++.h> using namespace std; #define maxn 200005 char s[maxn]; int n, x, y, c; long long odp; vector<int> v; int main(){ scanf("%s", s+1); n=strlen(s+1); for(int i=1; i<=n; i++){ char h=s[i]; if(h=='a' || h=='e' || h=='o' || h=='i' || h=='u' || h=='y'){ x++; y=0; } else{ y++; x=0; } if(x==3 || y==3){ v.push_back(i); if(x==3) x=2; if(y==3) y=2; } } for(int i=1; i<=n; i++){ while(c<v.size() && v[c]<i+2) c++; if(c>=v.size()) break; odp+=n-v[c]+1; } printf("%lld\n", odp); } |
English