#P1320. Decompressing a Dot Matrix Pattern
Decompressing a Dot Matrix Pattern
Decompressing a Dot Matrix Pattern
You are given a compressed code that represents an (N \times N) dot matrix pattern consisting of binary digits (0 and 1). The compressed code is generated in a row-major order (from left to right and top to bottom) using the following method:
- The first number is (N), which represents both the number of rows and columns.
- The following numbers represent the counts of consecutive digits starting with 0 and alternating between 0 and 1. That is, the first count indicates how many 0's, the second count indicates how many 1's, the third count indicates how many 0's, and so on.
- It is guaranteed that the sum of these counts equals (N \times N).
For example, consider the dot matrix pattern below:
0001000 0001000 0001111 0001000 0001000 0001000 1111111
Its corresponding compressed code is: (7\ 3\ 1\ 6\ 1\ 6\ 4\ 3\ 1\ 6\ 1\ 6\ 1\ 3\ 7).
Your task is to reconstruct the original dot matrix (of size (N \times N)) from the given compressed code and print it. Each row of the output should contain exactly (N) characters (without any spaces).
inputFormat
A single line containing a sequence of space-separated integers. The first integer is (N) (the size of the dot matrix), and the subsequent integers represent alternating counts of 0's and 1's. The sum of these counts equals (N \times N).
outputFormat
Output the reconstructed dot matrix pattern as (N) lines, each containing exactly (N) binary digits (either 0 or 1) with no spaces.
sample
7 3 1 6 1 6 4 3 1 6 1 6 1 3 7
0001000
0001000
0001111
0001000
0001000
0001000
1111111
</p>