一看到该题就认为可以用最长公共子序列来解
于是写了一下,提交显示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!!!!
刚刚开始用循环数组时低维不应该循环,因为低维的以后会用到,因为是两层循环!!标记!!!
分享到:
相关推荐
北大POJ1936-All in All 解题报告+AC代码
北大POJ1016-Numbers That Count【字符串处理】 解题报告+AC代码
北大POJ初级-简单搜索 解题报告+AC代码
LeetCode判断字符串是否循环 :bookmark_tabs:Plan 动态规划 背包问题 动态规划 POJ 3267 POJ 1260 POJ 1015 POJ 3176 POJ 1080 POJ 1159 POJ 2533 POJ 1836 Leetcode 70 Leetcode 309 搜索 DFS POJ 2488 POJ 3083 ...
POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类
* 串:例如 poj1035、poj3080、poj1936。 * 排序:例如 poj2388、poj2299。 * 简单并查集的应用。 * 哈希表和二分查找等高效查找法:例如 poj3349、poj3274、poj2151、poj1840、poj2002、poj2503。 * 哈夫曼树...
北大POJ1094-Sorting It All Out 解题报告+AC代码
poj 2482 Stars in Your Window.md
poj 3763 Tour in Wonder Land.md
poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题...
北大POJ2388-Who's in the Middle 解题报告+AC代码
上面可能有poj的题目,hdu的题目,spoj的题目,sgu的题目,hust上的题目,fzu上的题目
北大POJ1584-A Round Peg in a Ground Hole 解题报告+AC代码
如果有了这个的话,学习起来更系统,更清爽!
poj分类poj分类poj分类poj分类
在进行ACM编程训练时做字符串专题的一些题目(POJ1782,POJ1790,POJ1951,POJ2003,POJ2121)
POJ第1861题源码 POJ第1861题源码 POJ第1861题源码
poj 1012解题报告poj 1012解题报告poj 1012解题报告poj 1012解题报告
poj 2329解题报告poj 2329解题报告poj 2329解题报告poj 2329解题报告
poj 1659解题报告poj 1659解题报告poj 1659解题报告poj 1659解题报告