AtCoder Regular Contest 131
B
Grid Repainting 4
AtCoder
⌀ 0
原题
← AC →
翻译中…

Problem Statement

翻译中…

We have a canvas represented as a $H \times W$ grid. Let $(i, j)$ denote the square at the $i$-th row $(1 \leq i \leq H)$ from the top and $j$-th column $(1 \leq j \leq W)$ from the left.

翻译中…

Initially, $(i, j)$ is in the following state.

翻译中…
  • If $c_{i, j}=$1: painted in Color 1.
  • If $c_{i, j}=$2: painted in Color 2.
  • If $c_{i, j}=$3: painted in Color 3.
  • If $c_{i, j}=$4: painted in Color 4.
  • If $c_{i, j}=$5: painted in Color 5.
  • If $c_{i, j}=$.: 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

翻译中…
  • $1 \leq H, W \leq 700$
  • $c_{i, j}$ 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:

翻译中…

H W
c_{1, 1}c_{1, 2}\ldotsc_{1, W}
c_{2, 1}c_{2, 2}\ldotsc_{2, W}
 :
c_{H, 1}c_{H, 2}\ldotsc_{H, W}

翻译中…

Output

翻译中…

Print a way to paint the squares in the following format. Here, $d_{i, j}$ should be the color of $(i, j)$ after painting the squares (it should be 1, 2, 3, 4, or 5).

翻译中…

d_{1, 1}d_{1, 2}\ldotsd_{1, W}
d_{2, 1}d_{2, 2}\ldotsd_{2, W}
 :
d_{H, 1}d_{H, 2}\ldotsd_{H, W}

翻译中…

If there are multiple ways to paint the squares under the condition, you may print any of them.

翻译中…

样例

Input #1
3 3
...
...
...
Output #1
132
313
541
Sample Output 1 corresponds to the following coloring. ![ ](https://img.atcoder.jp/arc131/35bb8a98465fbb2c889ea532d0985ff0.png)
Input #2
5 7
1.2.3.4
.5.1.2.
3.4.5.1
.2.3.4.
5.1.2.3
Output #2
1425314
2531425
3142531
4253142
5314253
Sample Output 2 corresponds to the following coloring. ![ ](https://img.atcoder.jp/arc131/a2fc3903965fd871d25e905fb95dbc6a.png)
Input #3
1 1
.
Output #3
4
题目信息
题号
arc131_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。