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_1 s_2 \dots s_{|s|}(其中 ∣s∣|s| 表示字符串 ss 的长度)的一个长度为 ∣x∣|x| 的子序列是指形如 x=sk1sk2…sk∣x∣x = s_{k_1} s_{k_2} \dots s_{k_{|x|}} 的字符串(满足 1≤k1<k2<⋯<k∣x∣≤∣s∣1 \le k_1 < k_2 < \dots < k_{|x|} \le |s|)。

给定两个字符串 ss 和 tt。考虑字符串 ss 的所有与字符串 tt 相等的子序列。问:字符串 ss 的每个字符是否都至少出现在其中一个这样的子序列中?换言之,是否对每个 ii(1≤i≤∣s∣1 \le i \le |s|),均存在字符串 ss 的一个子序列 x=sk1sk2…sk∣x∣x = s_{k_1} s_{k_2} \dots s_{k_{|x|}},使得 x=tx = t,且对某个 jj(1≤j≤∣x∣1 \le j \le |x|)有 kj=ik_j = 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.

第一行包含字符串 ss,第二行包含字符串 tt。每行仅由小写英文字母组成。给定的字符串非空,且每个字符串的长度不超过 2⋅1052 \cdot 10^5。

输出格式

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.

如果字符串 ss 的每个字符都至少出现在一个所述子序列中,则输出 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.

在第一个样例中,字符串 tt 可以作为字符串 ss 的子序列以三种方式出现:abab、abab 和 abab。在这些出现中,字符串 ss 的每个字符至少出现一次。

在第二个样例中,字符串 ss 的第 4 个字符未出现在字符串 tt 的任何一次出现中。

在第三个样例中,字符串 tt 在字符串 ss 中没有任何出现。

输入解题思路,AI测评打分。不知道怎么写?

首页