Construct Hdoj 5414 CRB and String

Source: Internet
Author: User

Topic Portal

Test instructions: To two string s,t, you can insert the character C (different from the previous one) after the S string, asking if you can convert s to t string

Construction: First lens > Lent or s[1]! = t[1] must be no, then t the same length of the first part of the same character in S to the same, otherwise it cannot be inserted, after the part as long as the same part all exist, the different parts can be arbitrarily inserted

/************************************************
* Author:running_time
* Created time:2015-8-20 15:29:43
* File name:i.cpp
************************************************/

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;

#define Lson L, Mid, RT << 1
#define Rson Mid + 1, R, RT << 1 | 1
typedef Long long ll;
const int maxn = 1e5 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
Char s[maxn], t[maxn];

bool judge(void) {
int lens = strlen (s + 1);
int lent = strlen (t + 1);
if (lens > lent | | s[1] ! = t[1]) return false;
int i, J;
For (j=2; J <= lent; ++ J) {
if (t[J]! = t[1]) break;
   }
For (i=1; I < J; ++ i) {
If (s[i]! = t[i]) re Turn false;
   }
while (i <= lens) {
While (J <= lent && s[i] != t [ J ]) + + j;
If (J > lent) return false;
I+ +; J ++;
   }
return true;
}

int main(void) { //hdoj 5414 CRB and String
int T; scanf ("%d", &T);
while (T--) {
scanf ("%s%s", s + 1, t + 1 );
puts (Judge () ? "Yes" : "No");
   }

return 0;
}

Construct Hdoj 5414 CRB and String

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.