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

C23天河寒假作业2-基础数据结构

Not Claimed
Status
Done
Problem
14
Open Since
2024-1-30 0:00
Deadline
2024-3-31 23:59
Extension
24 hour(s)