#P1319. Decompress the Dot Matrix Pattern

    ID: 14606 Type: Default 1000ms 256MiB

Decompress the Dot Matrix Pattern

Decompress the Dot Matrix Pattern

A Chinese character is represented by an N × N dot matrix pattern consisting of zeros and ones. This pattern is compressed into a sequence of numbers using the following rule: the matrix is read in row-major order (from left to right, top to bottom) and we count the number of consecutive digits. The first count represents the number of consecutive 0s starting from the first element, the second count represents the number of consecutive 1s that follow, the third count again represents the number of consecutive 0s, and so on. Note that the very first number in the input is N (i.e. the dimension of the matrix), and the remaining numbers, when summed up, equal N × N.

For example, consider the following 7×7 dot matrix pattern:

0001000
0001000
0001111
0001000
0001000
0001000
1111111

The corresponding compressed code is given by:

\(7\ 3\ 1\ 6\ 1\ 6\ 4\ 3\ 1\ 6\ 1\ 6\ 1\ 3\ 7\)

Your task is to decompress the given code to reconstruct and print the original dot matrix pattern.

inputFormat

The input consists of a single line containing space-separated integers. The first integer is N indicating the size of the matrix. The following integers represent the counts of consecutive zeros and ones (starting with zeros) in the matrix when read in row-major order. You can assume that the sum of these counts is exactly N × N.

outputFormat

Output the N × N matrix pattern. Each of the N lines should contain exactly N characters (either '0' or '1') without any 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>