#C8468. Merge Binary Strings
Merge Binary Strings
Merge Binary Strings
Given a list of binary numbers (as strings) with possibly varying lengths, your task is to merge them into a single binary string using the bitwise OR operation. In order to perform this operation, first pad each binary string with leading zeros so that they all have the same length as the longest string. Then, for each digit position, output '1' if at least one of the padded strings has '1' in that position; otherwise, output '0'.
Mathematically, if the padded binary strings are denoted by (b_1, b_2, \ldots, b_n) (each of length (L)), then the merged binary string (r) is defined digit-wise as follows:
[ r_i = \bigvee_{j=1}^{n} (b_{j,i}) \quad \text{for } i=1,2,\ldots,L ]
If the list is empty, output an empty string.
inputFormat
The first line contains an integer (n) representing the number of binary strings. The following (n) lines each contain a binary string.
outputFormat
Output a single line containing the merged binary string after performing the bitwise OR operation.## sample
4
1100
101
111
000
1111