Match the string--hdu1797 (analog)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.