#P2410. [SDOI2009] 最优图像

    ID: 1473 远端评测题 2000ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2009各省省选山东Special Judge最短路

[SDOI2009] 最优图像

Description

This picture can be regarded as a black-and-white image with n×mn \times m pixels. For convenience, we use 00 for white pixels and 11 for black pixels. Xiao E believed the picture hid some secrets, so he recorded the number of black pixels in each row and each column to study later.

One day, Xiao W accidentally got the picture wet, and the original image became hard to recognize. Anxious, he asked Xiao E to help restore it. Based on the wet picture, they could not determine the exact image, but they could estimate the probability pi,j%p_{i, j}\% that each pixel was originally black. Then, the occurrence probability of a complete image can be defined as:

$$\prod\limits_{i = 1}^n \prod\limits_{j = 1}^{m} p_{i, j}\% \times [s_{i, j} = 1]$$

Here si,js_{i, j} denotes whether the pixel in the restored image is white (00) or black (11), and [si,j=1][s_{i, j} = 1] means the value of this expression is 11 if si,j=1s_{i, j} = 1, and 00 otherwise. In other words, the occurrence probability of a complete image equals the product of the probabilities of all its black pixels. Clearly, the set of black pixels in the image cannot include any pixel with probability 00.

However, Xiao E could not solve this either. So they turned to Xiao F, a programmer — that is, you. Please, based on the above information, tell them which image is the most likely original image.

Input Format

The first line contains two integers n,mn, m, denoting the size of the image.

Lines 22 to (n+1)(n + 1) each contain mm integers. In the (i+1)(i + 1)-th line, the jj-th integer pi,jp_{i, j} denotes the probability that the pixel in row ii, column jj is black.

The next line contains nn integers. The ii-th integer aia_i denotes the number of black pixels in row ii.

The next line contains mm integers. The ii-th integer bib_i denotes the number of black pixels in column ii.

Output Format

This problem uses a Special Judge.

Output nn lines, each containing a string of length mm consisting only of characters 0 and 1, representing your answer.

The input guarantees that at least one valid image exists. If there are multiple optimal images, output any one of them.

2 2
90 10
20 80
1 1
1 1

10
01

Hint

Explanation of Sample Input/Output 1

There are two possible images:

01
10
10
01

The occurrence probability of the former is 0.1×0.2=0.020.1×0.2=0.02, and that of the latter is 0.9×0.8=0.720.9×0.8=0.72, so the latter is the optimal image.


Constraints

  • For 20%20\% of the testdata, n,m5n, m \leq 5.
  • For 100%100\% of the testdata, 1n,m1001 \leq n, m \leq 100, 0pi,j1000 \leq p_{i, j} \leq 100, 0aim0 \leq a_i \leq m, 0bin0 \leq b_i \leq n.

Thanks to

https://www.luogu.com.cn/user/23118
ing the spj.

Translated by ChatGPT 5