SPOJ BITMAP

From Algorithmist
Jump to navigation Jump to search

206 (BITMAP) - BITMAP[edit]

Summary[edit]

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.

Explanation[edit]

based on bfs

Gotchas[edit]

Notes[edit]

Implementations[edit]

Optimizations[edit]

Input[edit]

1
3 4
0001
0011
0110

Output[edit]

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

References[edit]