All in All POJ1936

来源:互联网 发布:77pepecom现在域名 编辑:程序博客网 时间:2024/05/16 07:54

All in All
Time Limit: 1000MS Memory Limit: 30000KB 64bit IO Format: %lld & %llu

Submit Status

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

数电实验做砸了。写道水题冷静冷静大哭,好好的为什么要学数电呢?哎。。。。

代码如下,不多说

#include<iostream>#include<cstring>#include<string>#include<algorithm>using namespace std;int main(){string str1,str2;while(cin>>str1>>str2){    int len=str1.length();int len2=str2.length();bool flag=false;for(int i=0,j=0;i<len2;i++){        if(str1[j]==str2[i])j++;        if(j>=len){flag=true;break;}    }    if(flag)cout<<"Yes"<<endl;    else cout<<"No"<<endl;}return 0;}


0 0
原创粉丝点击