thermometre

The answer to the black squares problem

For each small square, it has a colour and a number. The number of thesmall square equals how long the length of biggest black square whose bottom right corner is this small square is.

1. Search the first row and the first line. If the small square is black, the number of it will be 1. If the small square is white, the number of it will be 0

2. Search the next row and line. If the small square is black, the number of it will be 1 plus the smallest one of a,b,c. If the small square is white, the number will be 0



3. Repeat doing 2 until each small square has a number

4. Find the biggest number and it is the answer

Time consume: O(nm)

评论