#P15756. [JAG 2025 Summer Camp #1] Chairs
[JAG 2025 Summer Camp #1] Chairs
题目描述
There are chairs arranged in rows and columns. We denote the chair in the -th row from the top and the -th column from the left by .
Some chairs may have luggage placed on them. The situation of the chairs is represented by strings , each of length . If the -th character of is ‘#’, then there is luggage on . If it is ‘.’, then there is no luggage on . It is guaranteed that there is at least one chair on which there is no luggage.
We want to seat people on these chairs. At most one person can sit on each chair, and a person cannot sit on a chair that has luggage on it. Moreover, two people cannot sit on chairs that are adjacent to each other vertically or horizontally. Under these conditions, we want to seat as many people as possible. Let be the maximum number of people we can seat observing these rules.
Now, suppose one person arrives. For each chair, determine whether we may seat this person there. Specifically, determine whether it is possible to seat this person on that chair, and in addition, still be able to seat more people under the rules.
输入格式
The input is given in the following format:
$$\begin{aligned} &H \ W \\ &S_1 \\ &S_2 \\ &\vdots \\ &S_H \end{aligned} $$- is a string of length consisting of ‘#’ and ‘.’ ().
- There exists such that the -th character of is ‘.’.
- and are integers.
输出格式
Output lines. On the -th line (), output a string of length .
For each , if we can seat the newly arrived person on , then the -th character of the string on the -th line must be ‘1’. Otherwise, it must be ‘0’.
3 4
##..
....
#.##
0011
1011
0100