HDU 5414 (2015 + schools)-CRB and string (string processing)

Source: Internet
Author: User

Title Address: HDU 5414
Test instructions: Ask to determine whether the string s can be added several characters to get the string t
Idea: This problem looks complex, in fact, a careful analysis, successful conversion contains only two cases. The first is that because the new character required to be inserted differs from the character C in front of it, if there is x continuous C in T, then there must be x consecutive C in S, and the second is a discontinuous substring of t that must be s.

#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>#include <bitset>#pragma COMMENT (linker, "/stack:102400000,102400000")using namespace STD;typedef Long LongLL;Const intinf=0x3f3f3f3f;Const DoublePi=ACOs(-1.0);Const Doubleesp=1e-7;Const intmaxn=1e5+Ten;CharS[MAXN],T[MAXN];intN,m;intLen1,len2;intCheck () {intI,j; for(i=1; i<len2;i++)if(t[i]!=t[0]) Break;//Find the first discontinuous position of the T-string     for(j=0; j<i;j++)//See if the first I substring of S is continuous        if(S[j]!=t[j])return 0; for(;j<len1;) { for(; i<len2;i++) {//Find the next and s equal places            if(T[i]==s[j]) Break; }if(I==LEN2)return 0;//If T is finished, it's not yet out of the proof that s is not a substring of Ti++;    j + +; }return 1;}intMain () {intTscanf("%d", &t); while(t--) {scanf('%s '%s ', s,t); len1=strlen(s); Len2=strlen(t);if(check ())puts("Yes");Else            puts("No"); }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 5414 (2015 + schools)-CRB and string (string processing)

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.