atcoder#ARC131B. [ARC131B] Grid Repainting 4
[ARC131B] Grid Repainting 4
Score : points
Problem Statement
We have a canvas represented as a grid. Let denote the square at the -th row from the top and -th column from the left.
Initially, is in the following state.
- If
1
: painted in Color 1. - If
2
: painted in Color 2. - If
3
: painted in Color 3. - If
4
: painted in Color 4. - If
5
: painted in Color 5. - If
.
: not yet painted.
Create a way to paint each unpainted square in Color 1, 2, 3, 4, or 5 so that no two horizontally or vertically adjacent squares have the same color. It is not allowed to change the color of a square that is already painted.
Constraints
- is
1
,2
,3
,4
,5
, or.
. - At least one square is unpainted.
- There is at least one way to paint the squares under the condition.
Input
Input is given from Standard Input in the following format:
Output
Print a way to paint the squares in the following format. Here, should be the color of after painting the squares (it should be 1
, 2
, 3
, 4
, or 5
).
If there are multiple ways to paint the squares under the condition, you may print any of them.
3 3
...
...
...
132
313
541
Sample Output 1 corresponds to the following coloring.
5 7
1.2.3.4
.5.1.2.
3.4.5.1
.2.3.4.
5.1.2.3
1425314
2531425
3142531
4253142
5314253
Sample Output 2 corresponds to the following coloring.
1 1
.
4