您的位置:首页 > 其它

J - All in All UVA - 10340

2017-07-21 19:06 323 查看
You have devised a new encryption technique which encodes a message by inserting between its charactersrandomly generated strings in a clever way. Because of pending patent issues we will not discuss indetail 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 finalstring.Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can removecharacters
from t such that the concatenation of the remaining characters is s.InputThe input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCIIcharacters separated by whitespace. Input is terminated by EOF.OutputFor each test case
output, if s is a subsequence of t.Sample Inputsequence subsequenceperson compressionVERDI vivaVittorioEmanueleReDiItaliacaseDoesMatter CaseDoesMatterSample OutputYesNoYesNo
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main()
{
char s1[1000001];
char s2[1000001];
int i,j;
while(scanf("%s%s",s1,s2)!=EOF)
{
int l=strlen(s1);
j=l-1;
for(i=strlen(s2)-1; i>=0; i--)
{
if(s2[i]==s1[j])
j--;
}
if(j==-1)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: