#C. 填涂颜色

    Type: RemoteJudge 1000ms 125MiB

填涂颜色

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

由数字 00 组成的方阵中,有一任意形状闭合圈,闭合圈由数字 11 构成,围圈时只走上下左右 44 个方向。现要求把闭合圈内的所有空间都填写成 22。例如:6×66\times 6 的方阵(n=6n=6),涂色前和涂色后的方阵如下:

0 0 0 0 0 0
0 0 1 1 1 1
0 1 1 0 0 1
1 1 0 0 0 1
1 0 0 0 0 1
1 1 1 1 1 1
0 0 0 0 0 0
0 0 1 1 1 1
0 1 1 2 2 1
1 1 2 2 2 1
1 2 2 2 2 1
1 1 1 1 1 1

输入格式

每组测试数据第一行一个整数 n(1n30)n(1 \le n \le 30)

接下来 nn 行,由 0011 组成的 n×nn \times n 的方阵。

方阵内只有一个闭合圈,圈内至少有一个 00

输出格式

已经填好数字 22 的完整方阵。

6
0 0 0 0 0 0
0 0 1 1 1 1
0 1 1 0 0 1
1 1 0 0 0 1
1 0 0 0 0 1
1 1 1 1 1 1

0 0 0 0 0 0
0 0 1 1 1 1
0 1 1 2 2 1
1 1 2 2 2 1
1 2 2 2 2 1
1 1 1 1 1 1

提示

对于 100%100\% 的数据,1n301 \le n \le 30

0228c班开学考

Not Attended
Status
Done
Rule
IOI
Problem
5
Start at
2025-2-28 18:30
End at
2025-2-28 21:00
Duration
2.5 hour(s)
Host
Partic.
27