1202: 填涂颜色

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:1 解决:0

题目描述

由数字 lns="http://www.w3.org/1998/Math/MathML">0 组成的方阵中,有一任意形状闭合圈,闭合圈由数字 lns="http://www.w3.org/1998/Math/MathML">1 构成,围圈时只走上下左右 lns="http://www.w3.org/1998/Math/MathML">4 个方向。现要求把闭合圈内的所有空间都填写成 lns="http://www.w3.org/1998/Math/MathML">2。例如:lns="http://www.w3.org/1998/Math/MathML">6×6 的方阵(lns="http://www.w3.org/1998/Math/MathML">=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

输入

每组测试数据第一行一个整数 lns="http://www.w3.org/1998/Math/MathML">(130)

接下来 lns="http://www.w3.org/1998/Math/MathML"> 行,由 lns="http://www.w3.org/1998/Math/MathML">0 和 lns="http://www.w3.org/1998/Math/MathML">1 组成的 lns="http://www.w3.org/1998/Math/MathML">× 的方阵。

方阵内只有一个闭合圈,圈内至少有一个 lns="http://www.w3.org/1998/Math/MathML">0

输出

已经填好数字 lns="http://www.w3.org/1998/Math/MathML">2 的完整方阵。

样例输入

复制
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

提示

对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">130