QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#1693. 求和

统计

给你一个长为 $n$ 的数列 $a_1,a_2,\dots,a_n$,请你构造一个整数序列 $b_1, b_2,\dots, b_n$,满足

  • 对于所有的 $i$,有 $b_i \ge a_i$。
  • 在二进制加法中,将 $b$ 数列求和时不发生进位。
  • 满足以上两条条件的数列中,你需要最小化 $\sum_{i=1}^n b_i$。

本题采用多组数据。

输入格式

第一行一个数 $T$,表示数据组数。

每组数据第一行一个正整数 $n$,表示数列长度。

接下来 $n$ 行,每行一个仅包含 $\texttt{01}$ 的串,表示数列中的数的二进制表示,保证以 $\texttt{1}$ 开头。

输出格式

对于每组数据,一行一个二进制数,表示 $\sum_{i=1}^n b_i$ 的二进制表示。

样例一

input

4
2
10
10
2
10100
1001
3
1
1
110
2
1101
101011

output

110
11101
1011
111011

explanation

对于第一组数据,$b=((100)_2, (10)_2)$。

对于第二组数据,$b=a$。

对于第三组数据,$b=((10)_2,(1)_2,(1000)_2)$。

对于第四组数据,$b=((10000)_2,(101011)_2)$。

样例二

见下发文件。

限制与约定

记二进制数最大串长为 $\max L$,单个测试点中单个数据总串长为 $\sum L$,所有数据总串长为 $\sum^2 L$。

对于 $100\%$ 的数据,保证 $T\le 10, 2\le n \le 10^5, 1\le \max L\le \sum L \le 10^5, 1\le \sum^2 L \le 10^6$。

测试点编号$n$$\max L$特殊限制
$1$$=2$$\le 10$
$2$$\le 20$
$3$$\le 50$
$4$$\le 300$
$5$$\le 10^3$
$6$$\le 10^5$
$7$$\le 8$$\le 8$
$8$$\le 50$
$9$$\le 100$
$10$
$11$$\le 10^3$$\sum L \le 10^3$
$12$
$13$
$14$
$15$
$16$$\le 10^5$$\sum^2 L \le 3\times 10^5$,每个二进制数都是 $2$ 的整次幂
$17$每个二进制数都是 $2$ 的整次幂
$18$
$19$$\sum^2 L \le 3\times 10^5$
$20$
$21$
$22$
$23$
$24$
$25$

时间限制:$1\texttt{s}$

空间限制:$512\texttt{MB}$

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.