现在的位置: 首页 > 综合 > 正文

POJ 1936 All in all 简单字符串比较

2013年10月22日 ⁄ 综合 ⁄ 共 2012字 ⁄ 字号 评论关闭

 

一看到该题就认为可以用最长公共子序列来解
于是写了一下,提交显示MLE,改成循环数组又WA,不知道哪里问题
看到别人的解法,感觉思维方式很特别,很好,循环长串指针,比较长串和短串的一位,如果相等,短串指针加一
最后判断一下短串的指针有没有指到最后,如果移动到最后就说明查长串包含短串,否则.....
也提醒一下自己的思维定势
All in All
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 17955   Accepted: 7127

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 subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter

Sample Output

Yes
No
Yes
No
LCS  AC!!!!
刚刚开始用循环数组时低维不应该循环,因为低维的以后会用到,因为是两层循环!!标记!!!

 

抱歉!评论已关闭.