POJ 1936.All in all

Source: Internet
Author: User

All on all Time limit:1000MS Memory Limit:30000KB 64bit IO Format:%i64d &%i64 U Submit Status Practice POJ 1936

Description

You are devised a new encryption technique which encodes a message by inserting between its characters randomly generated Strings in a clever. Because of pending patent issues we won't discuss in detail how the strings is generated and inserted into the Origina L message. To validate your method, however, it's necessary to write a program that checks if the message was really encoded in the F Inal string.

Given-strings s and T, you had to decide whether s are a subsequence of T, i.e. if you can remove characters from T su CH, the concatenation of the remaining characters is S.

Input

The input contains several testcases. Each are specified by and strings s, T of alphanumeric ASCII characters separated by whitespace. The length of S and T would no more than 100000.

Output

For each test, the output "Yes", if S is a subsequence of t,otherwise output "No".

Sample Input

Sequence Subsequenceperson Compressionverdi vivavittorioemanuelerediitaliacasedoesmatter CaseDoesMatter

Sample Output

Yesnoyesno

It should be a water problem ~

Use two variables to record the position of the string pointing to S, T.

If equal, then point to S of +1

Look at the end of the loop s

AC Code: GITHUB

1 /*2 By:ohyee3 Github:ohyee4 Homepage:http://www.oyohyee.com5 Email:[email protected]6 Blog:http://www.cnblogs.com/ohyee/7 8 かしこいかわいい? 9 エリーチカ! Ten to write out the хорошо code OH ~ One */ A  -#include <cstdio> -#include <algorithm> the#include <cstring> -#include <cmath> -#include <string> -#include <iostream> +#include <vector> -#include <list> +#include <queue> A#include <stack> at#include <map> - using namespacestd; -  - //DEBUG MODE - #defineDebug 0 -  in //Loops - #defineREP (n) for (int o=0;o<n;o++) to  + Const intMAXN =100005; -  the BOOLDo () { *     CharS[MAXN],T[MAXN]; $     if(SCANF ("%s%s", s,t) = =EOF)Panax Notoginseng         return false; -      the     intT_len =strlen (t); +     intS_len =strlen (s); A  the     intit =0; +      for(inti =0; I < t_len;i++) { -         if(S[it] = =T[i]) $it++; $         if(It = =S_len) -              Break; -     } the  -printf"%s\n", (it = = S_len)?"Yes":"No");Wuyi  the     return true; - } Wu  - intMain () { About      while(Do ()); $     return 0; -}

POJ 1936.All in all

Related Article

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.