logo AlgoBeat OnlineJudge
登录 注册

#215711. [ICPC 2025 Jakarta R] Binary Grid

内存限制:2048 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given an array containing non-negative integers. You have to construct a binary grid of size such that:

  • for any cell with value , any of its adjacent cells, i.e. cells that share one of its four sides, must have the value .
  • the number of cells with value in row is exactly .

Find any such binary grid or tell that it's impossible to construct.

输入格式

The first line contains two integers and ().

The next line contains integers containing ().

输出格式

Output lines, each containing characters of either or representing the binary grid you constructed. If multiple construction exists, you may output any of them. If such a grid does not exist, output .

样例

样例输入 1

6 7
4 3 2 2 3 4

样例输出 1

1010101
0101010
1010000
0000101
0101010
1010101

样例输入 2

2 2
2 2

样例输出 2

-1