103492: [Atcoder]ABC349 C - Airport Code

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:18 Solved:0

Description

Score: $300$ points

Problem Statement

A string $T$ of length $3$ consisting of uppercase English letters is an airport code for a string $S$ of lowercase English letters if and only if $T$ can be derived from $S$ by one of the following methods:

  • Take a subsequence of length $3$ from $S$ (not necessarily contiguous) and convert it to uppercase letters to form $T$.
  • Take a subsequence of length $2$ from $S$ (not necessarily contiguous), convert it to uppercase letters, and append X to the end to form $T$.

Given strings $S$ and $T$, determine if $T$ is an airport code for $S$.

Constraints

  • $S$ is a string of lowercase English letters with a length between $3$ and $10^5$, inclusive.
  • $T$ is a string of uppercase English letters with a length of $3$.

Input

The input is given from Standard Input in the following format:

$S$
$T$

Output

Print Yes if $T$ is an airport code for $S$, and No otherwise.


Sample Input 1

narita
NRT

Sample Output 1

Yes

The subsequence nrt of narita, when converted to uppercase, forms the string NRT, which is an airport code for narita.


Sample Input 2

losangeles
LAX

Sample Output 2

Yes

The subsequence la of losangeles, when converted to uppercase and appended with X, forms the string LAX, which is an airport code for losangeles.


Sample Input 3

snuke
RNG

Sample Output 3

No

Input

Output

分数:300分

问题描述

长度为 $3$ 的由大写英文字母组成的字符串 $T$ 是长度为小写英文字母的字符串 $S$ 的一个机场代码,当且仅当 $T$ 可以通过以下方法之一从 $S$ 得出:

  • 从 $S$ 中取一个长度为 $3$ 的子序列(不一定是连续的),然后将其转换为大写字母组成 $T$。
  • 从 $S$ 中取一个长度为 $2$ 的子序列(不一定是连续的),将其转换为大写字母,然后在末尾添加 X 以组成 $T$。

给定字符串 $S$ 和 $T$,判断 $T$ 是否是 $S$ 的机场代码。

约束

  • $S$ 是长度在 $3$ 到 $10^5$ 之间(含两端)的由小写英文字母组成的字符串。
  • $T$ 是长度为 $3$ 的由大写英文字母组成的字符串。

输入

输入通过标准输入给出以下格式:

$S$
$T$

输出

如果 $T$ 是 $S$ 的机场代码,打印 Yes,否则打印 No


样例输入1

narita
NRT

样例输出1

Yes

narita 的子序列 nrt 转换为大写后形成字符串 NRT,是 narita 的机场代码。


样例输入2

losangeles
LAX

样例输出2

Yes

losangeles 的子序列 la 转换为大写后加上 X 形成字符串 LAX,是 losangeles 的机场代码。


样例输入3

snuke
RNG

样例输出3

No

加入题单

算法标签: