QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#162. 兼并与收购

Statistiques

公司 $S$ 的 CEO 计划与另一家名为 $T$ 的公司合并。CEO 希望在合并过程中保留原始公司名称 $S$,并声称两家公司的名称混合成了一个新的名称。

CEO 坚持认为混合后的公司名称是按以下方式产生的:

设 $s$ 为 $S$ 的任意子序列,$t$ 为 $T$ 的任意子序列。合并后的新公司名称必须是一个与 $S$ 长度相同的字符串,该字符串通过交替排列 $s$ 和 $t$ 中的字符获得。更正式地说,$s_0 + t_0 + s_1 + t_1 + \dots$ 或 $t_0 + s_0 + t_1 + s_1 + \dots$ 可以用作合并后的公司名称。此处,$s_k$ 表示字符串 $s$ 的第 $k$ 个字符(从 0 开始计数)。请注意,如果 $S$ 的长度为奇数,则 $s$ 和 $t$ 的长度将会不同。在这种情况下,合并后的公司名称由 $s_0 + t_0 + \dots + t_{|S|/2} + s_{|S|/2+1}$ 或 $t_0 + s_0 + \dots + s_{|S|/2} + t_{|S|/2+1}$ 获得($|S|$ 表示 $S$ 的长度,“/” 表示整数除法)。

字符串的子序列是指通过从原始字符串中删除零个或多个字符而获得的字符串。例如,“abe”、“abcde” 和 “”(空字符串)都是字符串 “abcde” 的子序列。

你是收购公司的一名程序员。你的任务是编写一个程序,判断是否可以通过混合这两家公司的名称来得到原始公司名称 $S$。

输入格式

第一行包含一个字符串 $S$,表示你所属公司的名称。 第二行包含一个字符串 $T$,表示计划合并的目标公司的名称。这两个名称 $S$ 和 $T$ 均为非空,且长度相同,不超过 $10^3$ 个字符,所有字符均为小写英文字母。

输出格式

如果可以通过组合 $S$ 和 $T$ 得到原始公司名称,则输出 “Yes”,否则输出 “No”。

样例

样例输入 1

acmicpc
tsukuba

样例输出 1

No

样例输入 2

hoge
moen

样例输出 2

Yes

样例输入 3

abcdefg
xacxegx

样例输出 3

Yes

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.