#P1924. 贴海报

贴海报

Description

There is a wall of size n×mn\times m with several holes on it. You need to paste posters on the wall. Each poster is a 2×32\times 3 rectangle, with each side parallel or perpendicular to the wall’s edges. A poster can be placed horizontally or vertically, but no poster may cover any hole. What is the maximum number of posters that can be placed on this wall?

Input Format

The first line contains 22 integers nn and mm, indicating that the wall size is n×mn\times m.

The next nn lines each contain mm integers 00 or 11. A 11 indicates that position has a hole, and a 00 indicates no hole.

Output Format

Output the maximum number of posters that can be placed.

6 6
0 0 0 1 0 0 
0 1 0 0 0 0
0 0 0 0 0 1
0 0 0 0 0 1
0 0 0 0 0 0
0 0 0 1 0 0
3

Hint

The testdata guarantees that 1n1501\leq n\leq 150, 1m101\leq m\leq 10.

Translated by ChatGPT 5