QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 1024 MB 總分: 100 难度: [顯示] 可 Hack ✓
统计

Little Cyan Fish 有两个二进制字符串 $s$ 和 $t$。二进制字符串是指仅由 0 或 1 组成的字符串。

对于一个二进制字符串 $s$,令 $c_0(s)$ 为 $s$ 中 0 的个数,$c_1(s)$ 为 $s$ 中 1 的个数。显然,$c_0(s) + c_1(s) = |s|$,因为 $s$ 仅包含 0 和 1。

Little Cyan Fish 想要将 $s$ 分割成 $k = |t|$ 个子串 $\sigma_1, \sigma_2, \dots, \sigma_k$,换句话说,$s = \sigma_1 + \sigma_2 + \dots + \sigma_k$。对于每个 $i$,$\sigma_i$ 必须满足以下条件:

  • 如果 $t_i = 0$,则 $c_0(\sigma_i) > c_1(\sigma_i)$。
  • 如果 $t_i = 1$,则 $c_0(\sigma_i) < c_1(\sigma_i)$。

请帮助 Little Cyan Fish 找到一种分割字符串的方法,或者报告无法满足他的要求!

输入格式

输入包含多组测试数据。第一行包含一个整数 $T$ ($T \ge 1$),表示测试数据的组数。对于每组测试数据:

第一行包含一个字符串 $s$ ($1 \le |s| \le 10^6$)。 下一行包含一个字符串 $t$ ($1 \le |t| \le |s|$)。

保证所有测试数据的 $|s|$ 之和不超过 $10^6$。

输出格式

对于每组测试数据:

如果无法满足 Little Cyan Fish 的要求,输出一行,包含单词 “No”。 否则,第一行输出单词 “Yes”。

为了减小输出规模,请按以下格式输出解法: 下一行输出一个长度为 $|A| = |s|$ 的二进制字符串 $A$,描述该解法。如果你在 $s$ 的第 $i$ 位和第 $i+1$ 位之间进行分割,则 $A$ 的第 $i$ 位标记为 1。否则,$A$ 的第 $i$ 位标记为 0。特别地,$A_{|s|}$ 必须始终为 1,因为字符串总是以最后一个字符结尾。

例如,如果你想将字符串 00101010 分割成三个片段 00, 10101, 0,则你应该输出 01000011。

样例

样例输入 1

3
1001
0
111
1
011011010011101
110111

样例输出 1

No
Yes
001
Yes
000011000110011

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.