CF223B.Two Strings
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A subsequence of length |x| of string s = _s_1_s_2... s|s| (where |s| is the length of string s) is a string x = _s__k_1_s__k_2... s__k|x| (1 ≤ _k_1 < _k_2 < ... < k|x| ≤ |s|).
You've got two strings — s and t. Let's consider all subsequences of string s, coinciding with string t. Is it true that each character of string s occurs in at least one of these subsequences? In other words, is it true that for all i (1 ≤ i ≤ |s|), there is such subsequence x = _s__k_1_s__k_2... s__k|x| of string s, that x = t and for some j (1 ≤ j ≤ |x|) k__j = i.
字符串 s=s1s2…s∣s∣(其中 ∣s∣ 表示字符串 s 的长度)的一个长度为 ∣x∣ 的子序列是指形如 x=sk1sk2…sk∣x∣ 的字符串(满足 1≤k1<k2<⋯<k∣x∣≤∣s∣)。
给定两个字符串 s 和 t。考虑字符串 s 的所有与字符串 t 相等的子序列。问:字符串 s 的每个字符是否都至少出现在其中一个这样的子序列中?换言之,是否对每个 i(1≤i≤∣s∣),均存在字符串 s 的一个子序列 x=sk1sk2…sk∣x∣,使得 x=t,且对某个 j(1≤j≤∣x∣)有 kj=i?
输入格式
The first line contains string s, the second line contains string t. Each line consists only of lowercase English letters. The given strings are non-empty, the length of each string does not exceed 2·105.
第一行包含字符串 s,第二行包含字符串 t。每行仅由小写英文字母组成。给定的字符串非空,且每个字符串的长度不超过 2⋅105。
输出格式
Print "Yes" (without the quotes), if each character of the string s occurs in at least one of the described subsequences, or "No" (without the quotes) otherwise.
如果字符串 s 的每个字符都至少出现在一个所述子序列中,则输出 Yes(不带引号);否则输出 No(不带引号)。
输入输出样例
输入#1
abab ab
输出#1
Yes
输入#2
abacaba aba
输出#2
No
输入#3
abc ba
输出#3
No
说明/提示
In the first sample string t can occur in the string s as a subsequence in three ways: abab, abab and abab. In these occurrences each character of string s occurs at least once.
In the second sample the 4-th character of the string s doesn't occur in any occurrence of string t.
In the third sample there is no occurrence of string t in string s.
在第一个样例中,字符串 t 可以作为字符串 s 的子序列以三种方式出现:abab、abab 和 abab。在这些出现中,字符串 s 的每个字符至少出现一次。
在第二个样例中,字符串 s 的第 4 个字符未出现在字符串 t 的任何一次出现中。
在第三个样例中,字符串 t 在字符串 s 中没有任何出现。
输入解题思路,AI测评打分。不知道怎么写?