#P3936. Coloring
Coloring
Description
is playing a game where he colors squares on a white paper with grid cells. However, messy coloring is not fun, so he came up with a peculiar problem:
In an grid, use different colors to try to color all cells. Different colors are represented by integers in . The coloring must satisfy the following conditions:
-
Each cell must be colored in exactly one color.
-
Color must color exactly cells. It is guaranteed that .
-
Consider cells that are adjacent up, down, left, or right and have the same color to be in the same connected component, and define as the number of grid edges between different connected components. See the sample explanation.
Now, wants to know, given , , and , whether you can construct a valid coloring that makes as small as possible.
Input Format
The first line contains three numbers, .
The second line contains numbers, where the -th number is .
Output Format
Output lines, each containing numbers, representing your constructed coloring with as small as possible.
2 3 3
1 2 3
2 3 1
2 3 3
Hint
| |
2 | 3 | 1
+ +---
2 | 3 3
|
For the sample, , consisting of three vertical edges and one horizontal edge.
Conventions
This problem is Special Judge.
For each test point, a threshold is set, and it is guaranteed that there exists a construction such that .
The score for your output will be computed as follows:
$$\begin{matrix}q&score&q&score\\\\ q \leq w&10&1.75w < q \leq 2w&5\\\\ w < q \leq 1.1w&9&2w < q \leq 2.3w&4\\\\ 1.1w < q \leq 1.25w&8&2.3w < q \leq 2.6w&3\\\\ 1.25w < q \leq 1.5w&7&2.6w < q \leq 3w&2\\\\ 1.5w < q \leq 1.75w&6&3w < q \leq 3.5w&1\end{matrix}$$If , it will be judged as Wrong Answer.
The score shown during the contest is the final score.
Constraints
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号