SPOJ BITMAP

206 (BITMAP) - BITMAP

 * SPOJ BITMAP

Summary
Within a rectangle, determine the distance from each pixel of said rectangle to the nearest specified pixels.

The input rectangle is provided as a grid of numbers, and a specified pixel is '1' insead of '0'. There is at least one marked pixel.

The distance is the sum of the row and column differences rather than a direct line.

Input
1 3 4 0001 0011 0110

Output
3 2 1 0 2 1 0 0 1 0 0 1