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 is a subsequence of T, i.e. if You can remove characters from T such so the concatenation of the remaining characters is s.
Input specification
The input contains several testcases. Each are specified by and strings s, T of alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF.
Output specification
For each test, the output, if s is a subsequence of T.
Sample Input
Sequence subsequence
Person compression
VERDI Vivavittorioemanuelerediitalia
Casedoesmatter Casedoesmatter
Sample Output
Yes
No
Yes
No
Crying blind. It seems such a simple question ... Hidden a lot of pits. (But it should still be my poor technology.) First, the topic does not give the data range of the string, because this re is two times (〒_〒), do not give the scope of the problem must be the array to open. The second is that they think about the problem when thinking too simple, just simple sample on the submission, not in-depth thinking of other special circumstances, because this WA two times (〒_〒) (PS: Estimate their algorithm is too poor, so you need to consider a lot of situations).
#include <stdio.h>#include<string.h>Charstr1[1000000],str2[1000000];intMain () {intI,j,flag; while(~SCANF ("%s%s", STR1,STR2)) {J=0; Flag=0; for(i=0; I<strlen (str1); i++) { for(; J<strlen (str2); J + +) { if(str1[i]==Str2[j]) { if(I==strlen (STR1)-1) Flag=1; Break; }} J++; } if(flag==1) printf ("yes\n"); Elseprintf"no\n"); } return 0;}
I-all in all