Optimization: minimizing errors in drawing

You are given a m * n grid, where each cell is marked as "b" or "w". You also get black and white paints. You can use k strokes, each of any color (black or white), a stroke is defined as coloring adjacent unpainted cells from the same line (which means that the stroke cannot go beyond the line, also if you lift the brush to the end of the line, which ends with this stroke). The goal is to minimize the number of errors, an error occurs if you draw a cell with the wrong color OR the cell remains unpainted. What is the best strategy?

+5
source share
1 answer

To solve the problem, a solution can be used to solve one line (that is, the minimum number of errors with k strokes in a given line BW).

For each line, specify a list of errors for the given number of strokes k_i = [0, 1, ..., min k needed to cover i-th row]. Now we have nlists (of different sizes). To find which lines to use "k" strokes for, iteratvelly pop the kelements from the top of the list, which stroke the cover of most cells.

So, the main task is to solve the problem with a single line, and I'm not sure how :-)

C - . - ceil( (C+1)/2 ). - , . ( ) ().

, , . . :

  • , ( ),

  • , .

, , , , . , , .

...

0

All Articles