题目:
CRB and String
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1114 Accepted Submission(s): 384
Problem Description
CRB has two strings
s and
t.
In each step, CRB can select arbitrary character
c of
s and insert any character
d (
d ≠ c) just after it.
CRB wants to convert
s to
t. But is it possible?
Input
There are multiple test cases. The first line of input contains an integer
T, indicating the number of test cases. For each test case there are two strings
s and
t, one per line.
1 ≤
T ≤
105
1 ≤
|s| ≤
|t| ≤
105
All strings consist only of lowercase English letters.
The size of each input file will be less than 5MB.
Output
For each test case, output "Yes" if CRB can convert s to t, otherwise output "No".
Sample Input
4 a b cat cats do do apple aapple
Sample Output
Author
KUT(DPRK)
Source
2015 Multi-University Training Contest 10
Recommend
wange2014
题意:给两个字符串s和t,可以在字符串s的任意字符后面添加和前一个字符不相同的字符,问s能不能转化为t。
思路:由于只能添加和前一个字符不同的字符,所以s和t的开始的字符必须相同并且s的起始连续的相同字符个数要大于等于t的,不然只能通过添加和前一个字符相同的字符来使s等于t。还有一个限制条件是s必须是t的子序列,也就是说s中出现的字符必须在t中出现而且s的字符的位置还要小于等于t中相应字符的位置,因为添加字符只能把字符向后移不能向前移。
代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include