[BOJ 7852] Nearest number - 2

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 128M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

Input is the matrix A of N by N non-negative integers.</p>

A distance between two elements Ai,j and Ap,q 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. 

입력 형식

Input file contains the number N followed by N2 integers, representing the matrix rowby-row. 

출력 형식

Output file must contain N2 integers, representing the modified matrix row-by-row. 

예제 입력

3
0 0 0
1 0 2
0 3 0

예제 출력

1 0 2
1 0 2
0 3 0

Comments

There are no comments at the moment.