QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#10909. 两个二进制字符串问题

統計

给定一个整数 $n$ 和两个长度为 $n$ 的二进制字符串 $a_1a_2 \dots a_n$(记作 $A$)和 $b_1b_2 \dots b_n$(记作 $B$)。

定义函数: $$f(l, r) = \begin{cases} 1, & \text{if } \sum_{i=l}^{r} a_i > \frac{r-l+1}{2} \\ 0, & \text{otherwise} \end{cases}$$

我们称一个整数 $k$ 是幸运的,当且仅当对于每个 $i(1 \le i \le n)$,都有 $f(\max(i - k + 1, 1), i) = b_i$ 成立。

对于每个整数 $k(1 \le k \le n)$,判断它是否是幸运的。

输入格式

第一行包含一个整数 $T(1 \le T \le 50000)$,表示测试用例的数量。

对于每个测试用例: 第一行包含一个整数 $n(1 \le n \le 50000)$,表示两个二进制字符串的长度。 第二行包含一个二进制字符串 $A$。 第三行包含一个二进制字符串 $B$。

保证 $\sum n \le 50000$。

输出格式

对于每个测试用例: 输出一行长度为 $n$ 的二进制字符串 $c_1c_2 \dots c_n$,其中当 $i$ 是幸运的时 $c_i = 1$,当 $i$ 不是幸运的时 $c_i = 0$。

样例

输入 1

2
5
11010
11000
8
11110000
11111100

输出 1

01000
00001100

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.