#include <iostream> #include <string> using namespace std; #define FORE(x, b, e) for(int x = b; x <= (e); ++x) #define FORL(x, b, e) for(int x = b; x < (e); ++x) #define P(x) cout <<#x <<'=' <<(x) <<" "; #define PP cout <<endl; #define Pv(x,a,b) cout << #x<<'=';for(int i=a;i<=b;i++)cout<<' '<<x[i];PP #define Pvv(x,y,a,b) cout <<#x <<#y <<'=';FORE(i,a,b)cout<<' '<<x[y[i]];PP typedef long long INT; typedef unsigned long long UINT; //#define get getchar_unlocked int isvowel(char v) { // return (0x208222>>(v&0x1f))&1; return (0x2208222>>(v&0x1f))&1; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string v; getline (cin,v); //**/P(v); int c, t=2, p=0, n=1; INT left=0, right=v.length(); UINT S=0; //P(v[1a])PP for ( string::iterator it=v.begin(); it!=v.end(); ++it) { ++p; c=isvowel(*it); //**/cout<<p<<":"<<n<<'['<<*it<<','<<c<<(it!=v.end())<<']'; if((t==c)&&(it!=v.end()-1)) { ++n; } else { //**/cout<<endl; if(t==c) { ++n; ++p; } if(n>2) { //**/P(n)P(left)P(p)P(right)P((it==v.end()-0))P(c==t)P(p-3-left)P(n-3)P(right-p+2)P(((p-3-left)+(n-3))*(right-p+2))PP S+=((p-3-left)+(n-3))*(right-p+2); left=p-3; } t=c; n=1; } } cout << S << 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 51 52 53 54 55 56 57 58 59 60 61 62 | #include <iostream> #include <string> using namespace std; #define FORE(x, b, e) for(int x = b; x <= (e); ++x) #define FORL(x, b, e) for(int x = b; x < (e); ++x) #define P(x) cout <<#x <<'=' <<(x) <<" "; #define PP cout <<endl; #define Pv(x,a,b) cout << #x<<'=';for(int i=a;i<=b;i++)cout<<' '<<x[i];PP #define Pvv(x,y,a,b) cout <<#x <<#y <<'=';FORE(i,a,b)cout<<' '<<x[y[i]];PP typedef long long INT; typedef unsigned long long UINT; //#define get getchar_unlocked int isvowel(char v) { // return (0x208222>>(v&0x1f))&1; return (0x2208222>>(v&0x1f))&1; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string v; getline (cin,v); //**/P(v); int c, t=2, p=0, n=1; INT left=0, right=v.length(); UINT S=0; //P(v[1a])PP for ( string::iterator it=v.begin(); it!=v.end(); ++it) { ++p; c=isvowel(*it); //**/cout<<p<<":"<<n<<'['<<*it<<','<<c<<(it!=v.end())<<']'; if((t==c)&&(it!=v.end()-1)) { ++n; } else { //**/cout<<endl; if(t==c) { ++n; ++p; } if(n>2) { //**/P(n)P(left)P(p)P(right)P((it==v.end()-0))P(c==t)P(p-3-left)P(n-3)P(right-p+2)P(((p-3-left)+(n-3))*(right-p+2))PP S+=((p-3-left)+(n-3))*(right-p+2); left=p-3; } t=c; n=1; } } cout << S << endl; return 0; } |