#P9293. [ROI 2018] Addition without carry
[ROI 2018] Addition without carry
Background
Translated from ROI 2018 Day2 T4. Сложение без переносов (Addition without carry).
Problem Description
For a set containing only natural numbers, if the sum of all numbers in the set equals the bitwise of all numbers in the set, then we call it a “beautiful set”.
Given , there exists a “beautiful set” consisting of the sequence , such that:
For all , , and
is minimized.
Find of the new sequence.
For convenience, the given are all in binary form, and your answer should also be in binary form.
Input Format
The first line contains an integer .
The next lines each contain a binary number .
Output Format
Output the resulting binary value of .
2
10
10
110
2
10100
1001
11101
3
1
1
110
1011
Hint
For all testdata, .
(In binary) the number of bits of does not exceed , and the sum of bit lengths of all does not exceed .
The subtask dependencies are for reference only. There are no subtask dependencies in the Luogu judging.
Constraints
| Subtask | Score | Subtasks that must be passed | ||
|---|---|---|---|---|
| 1 | 4 | |||
| 2 | 2 | 1 | ||
| 3 | 1,2 | |||
| 4 | 1--3 | |||
| 5 | 1--4 | |||
| 6 | 4 | Guaranteed that is a power of | ||
| 7 | 6, guaranteed that is a power of | |||
| 8 | 6,7, guaranteed that is a power of | |||
| 9 | U | |||
| 10 | U,1--4,9 | |||
| 11 | U,9 | |||
| 12 | U,1,9 | |||
| 13 | U,1,2,9,12 | |||
| 14 | 7 | U,1--3,6,9,12,13 | ||
| 15 | U,1--3,6,9,12--14 | |||
| 16 | 8 | U,1--4,6,7,9--15 | ||
| 17 | U,1--4,6,7,9--16 | |||
| 18 | 6 | U,1--4,6,7,9--17 | ||
| 19 | 7 | U,1--4,6,7,9--18 | ||
| 20 | U,1--4,6,7,9--19 | |||
| 21 | 6 | U,1--20 |
Translated by ChatGPT 5