Poj 1936 all in all (string)

Source: Internet
Author: User
All in all
Time limit:1000 ms
Memory limit:30000 K
Total submissions:27537
Accepted:11274

Description

You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. because of pending patent issues we will not discuss in detail how the strings are generated and inserted into the original message. to validate your method, however, it is necessary to write a program that checks if the message is really encoded in the final string.

Given two strings S and T, you have to decide whether s is a subsequence of T, I. e. if you can remove characters from t such that the concatenation of the remaining characters is S.

Input

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

Output

For each test case output "yes", if S is a subsequence of T, otherwise output "no ".

Sample Input

sequence subsequenceperson compressionVERDI vivaVittorioEmanueleReDiItaliacaseDoesMatter CaseDoesMatter

Sample output

YesNoYesNo

Source

Ulm Local 2002
Water...
Is to judge whether the string ST1 is a string of st2.
#include <iostream>using namespace std;int main(){char st1[100000],st2[100000];    __int64 l1,l2,i,j;while(cin>>st1>>st2){   i=0;j=0;l1=strlen(st1);l2=strlen(st2);while(1){if(i==l1){printf("Yes\n");break;}if(i<l1&&j==l2){printf("No\n");break;}if(st1[i]==st2[j]){i++;j++;}elsej++;}}return 0;}

Poj 1936 all in all (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.