http://acm.hdu.edu.cn/showproblem.php?pid=1797
is the simulation
My idea is to mark the location of ABA and H
And then you can tell if you're right.
And the last FKFKFKFK cross can also be
#include <iostream>#include<cstring>#include<algorithm>#include<queue>#include<cstdio>#include<cstdlib>#include<cctype>#include<math.h>#include<ctype.h>using namespacestd;#defineMemset (A, B) memset (A,b,sizeof (a))#defineN 101000typedefLong Longll;CharStr[n];intMain () {intT; scanf ("%d",&T); while(t--) { intflag=0; scanf ("%s", str); intlen=strlen (str); intabc,h; ABC=h=-1; if(Strstr (str,"ABA")) ABC=strstr (str,"ABA")-str; if(Strstr (str,"h")) H=strstr (str,"h")-str; if(abc==-1|| h==-1|| h==len-1) Flag=1; for(intI=0; i<abc; i++) { if(str[i]!='a') {flag=1; Break; } } intv1=0, v2=0; for(inti=abc+3; i) { if(str[i]!='b'&& str[i]!='D') {flag=1; Break; } if(str[i]=='D'&& str[i]=='b') {flag=1; Break; } if(str[i]=='b') V1++; if(str[i]=='D') V2++; } if(v1!=0&& v2==0) Flag=1; if(v1>1) Flag=1; V1=v2=0; for(inti=h+1; Str[i]; i++) { if(str[i]!='F'&& str[i]!='k') {flag=1; Break; } if(str[i]=='F') V1++; if(str[i]=='k') V2++; } if(v1==0&& v2==0) Flag=1; if(v1==0&& v2==0&& v1!=v2) Flag=1; if(flag==1) printf ("no\n"); Elseprintf ("yes\n"); } return 0;}
Match the string--hdu1797 (analog)