SPOJ BITMAP

From Algorithmist
Jump to: navigation, search

Contents

[edit] 206 (BITMAP) - BITMAP

[edit] 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.

[edit] Explanation

based on bfs

[edit] Gotchas

[edit] Notes

[edit] Implementations

[edit] Optimizations

[edit] Input

1
3 4
0001
0011
0110

[edit] Output

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

[edit] References

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox