ZOJ Problem Set - 2437
Input is the matrix A of N by N non-negative integers.
A distance between two elements Aij and Apq is defined as |i - p| + |j - q|.
Your program must replace each zero element in the matrix with the nearest non-zero one. If there are two or more nearest non-zeroes, the zero must be left in place.
1 <= N <= 200, 0 <= Ai <= 1000000
Input contains the number N followed by N^2 integers, representing the matrix row-by-row.
Output must contain N^2 integers, representing the modified matrix row-by-row.
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between
1 0 2
Source: Northeastern Europe 2003, Far-Eastern Subregion