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