#P2335. [SDOI2005] 位图
[SDOI2005] 位图
Description
You are given a monochrome bitmap of size , which contains at least one white pixel. We use to denote the pixel in the -th row and -th column, and define the distance between two points and as:
Your task is to read the bitmap and, for each pixel, compute the distance to the nearest white pixel. Output the result.
Input Format
The first line contains two space-separated integers and , where and .
Each of the next lines contains a string of length consisting of characters '0' and '1'. In the -th of these lines, if the -th character is '1', then pixel is white; otherwise it is black.
Output Format
Output an table of numbers. In this table, the -th number in the -th row is , which denotes the distance from pixel to its nearest white pixel.
3 4
0 0 0 1
0 0 1 1
0 1 1 0
3 2 1 0
2 1 0 0
1 0 0 1
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号