Build the board - MarisaOJ: Marisa Online Judge

Build the board

Time limit: 1000 ms
Memory limit: 256 MB
Consider a board with dimensions $n \times m$. You have the option to fill each cell on the board with either a $0$ or a $1$, following the given conditions: - The sum of values in the $i$th row should be equal to $r_i$. - The sum of values in the $j$th column should be equal to $c_j$. Let $S$ represent the concatenation of values on the board, starting from the top-left cell $A_{1,1}$ and moving in a row-major order to the bottom-right cell $A_{n,m}$. Find a way to fill the board such that the string $S$ is lexicographically minimum. ### Input - The first line contains two integers $n,m$. - The second line contains $n$ integers $r_i$. - The third line contains $m$ integers $c_j$. ### Output - Print $n$ lines, each line is a binary string of length $m$ denoting the board. If there is no satisfied board, print `-1`. ### Constraints - $1 \le n, m \le 80$. - $1 \le r_i \le m$. - $1 \le c_j \le n$. ### Example Input: ``` 3 3 2 1 2 1 2 2 ``` Output: ``` 011 001 110 ```