
ZOJ Problem Set  2437
Input is the matrix A of N by N nonnegative 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 nonzero one. If there are two or more nearest nonzeroes, the zero must be left in place. Constraints 1 <= N <= 200, 0 <= Ai <= 1000000
Input contains the number N followed by N^2 integers, representing the matrix rowbyrow.
Output must contain N^2 integers, representing the modified matrix rowbyrow.
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
output blocks.
1
1 0 2 Source: Northeastern Europe 2003, FarEastern Subregion 