#P15657. [ICPC 2025 Jakarta R] Binary Grid
[ICPC 2025 Jakarta R] Binary Grid
题目描述
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 .
6 7
4 3 2 2 3 4
1010101
0101010
1010000
0000101
0101010
1010101
2 2
2 2
-1