#P12556. [UOI 2024] Colorful Table
[UOI 2024] Colorful Table
Description
You are given a table of size , consisting of symbols , , .
Also, given are integers () and , where is the number of different symbols that can appear in the table. If equals , only the symbols and are available; if equals , the symbols , , are available.
You need to change the values of at most elements of the table so that there are no pairs of neighboring cells with the same value. Note that if , using the symbol when changing the values of the table cells is prohibited.
It is guaranteed that under the given constraints, there is a way to change the values of at most elements of the table so that there are no pairs of neighboring cells with the same value.
Note that there are no additional constraints in the problem.
Input Format
The first line contains two integers and () --- the number of rows and columns of the table respectively.
The second line contains two integers () and , representing the number of available symbols and the number of allowed changes in the table, respectively.
The next lines contain symbols each --- the elements of the table . If , then . If , then .
Output Format
Output lines of symbols each, describing the table after the changes.
If there are multiple correct answers, any of them is allowed.
3 3
3 4
RRR
RRR
RRR
RGR
GRG
RGR
3 2
2 3
RG
GG
GR
RG
GR
RG
Hint
Scoring
- ( points): $n = 1,\ c = 3,\ q = \lfloor \frac{n \cdot m}{2} \rfloor$;
- ( points): $n = 1,\ c = 2,\ q = \lfloor \frac{n \cdot m}{2} \rfloor$;
- ( points): ;
- ( points): all rows of table are the same, (for ), , ;
- ( points): all rows of table are the same, , ;
- ( points): $c = 3,\ q = \lfloor \frac{2 \cdot n \cdot m}{3} \rfloor$;
- ( points): $c = 3,\ n \leq 5,\ m \leq 100,\ q = \lfloor \frac{n \cdot m}{2} \rfloor$;
- ( points): ;
- ( points): .
京公网安备 11011102002149号