pseudocode problem

Please help me the algorithm

A matrix of dimensions n*n contains only zeros and ones as elements. Write psuedo
code to find the closest non zero element for every element with least complexity.
• Distance is Euclidean

• First solve for one dimentsion that is for every column individually.
• Then use the results for two dimensional problem.
Judging Criteria
• Least complexity of the solution

Input Matrix
0 0 0

0 0 0

0 0 1

Sqrt(8) sqrt(5) 2

Sqrt(5) sqrt(2) 1

2 1 0