Processing math: 100%
Build the board - MarisaOJ: Marisa Online Judge

Build the board

Time limit: 1000 ms
Memory limit: 256 MB
Consider a board with dimensions n×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 ith row should be equal to ri. - The sum of values in the jth column should be equal to cj. Let S represent the concatenation of values on the board, starting from the top-left cell A1,1 and moving in a row-major order to the bottom-right cell An,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 ri. - The third line contains m integers cj. ### 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≤n,m≤80. - 1≤ri≤m. - 1≤cj≤n. ### Example Input: 33212122 Output: 011001110