Nearest number - 2
Time Limit: 5000MS
Memory Limit: 65536K
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 N2 integers, representing the matrix row-by-row.
Output must contain N2 integers, representing the modified matrix row-by-row.
Northeastern Europe 2003, Far-Eastern Subregi