#P2410. [SDOI2009] 最优图像
[SDOI2009] 最优图像
Description
This picture can be regarded as a black-and-white image with pixels. For convenience, we use for white pixels and 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 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 denotes whether the pixel in the restored image is white () or black (), and means the value of this expression is if , and 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 .
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 , denoting the size of the image.
Lines to each contain integers. In the -th line, the -th integer denotes the probability that the pixel in row , column is black.
The next line contains integers. The -th integer denotes the number of black pixels in row .
The next line contains integers. The -th integer denotes the number of black pixels in column .
Output Format
This problem uses a Special Judge.
Output lines, each containing a string of length 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 , and that of the latter is , so the latter is the optimal image.
Constraints
- For of the testdata, .
- For of the testdata, , , , .
Thanks to
Translated by ChatGPT 5
京公网安备 11011102002149号