CF1404E.Bricks

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A brick is defined as a rectangle with integer side lengths with either width 11 or height 11 (or both).

There is an n×mn\times m grid, and each cell is colored either black or white. A tiling is a way to place bricks onto the grid such that each black cell is covered by exactly one brick, and each white cell is not covered by any brick. In other words, bricks are placed on black cells only, cover all black cells, and no two bricks overlap.

An example tiling of the first test case using 55 bricks. It is possible to do better, using only 44 bricks. What is the minimum number of bricks required to make a valid tiling?

输入格式

The first line contains two integers nn , mm ( 1n,m2001\le n, m\le 200 ) — the number of rows and columns, respectively.

The next nn lines describe the grid. The ii -th of these lines contains a string of length mm , where the jj -th character denotes the color of the cell in row ii , column jj . A black cell is given by "#", and a white cell is given by ".".

It is guaranteed that there is at least one black cell.

输出格式

Output a single integer, the minimum number of bricks required.

输入输出样例

  • 输入#1

    3 4
    #.##
    ####
    ##..

    输出#1

    4
  • 输入#2

    6 6
    ######
    ##....
    ######
    ##...#
    ##...#
    ######

    输出#2

    6
  • 输入#3

    10 8
    ####..##
    #..#.##.
    #..#.###
    ####.#.#
    ....####
    .###.###
    ###.#..#
    ########
    ###..###
    .##.###.

    输出#3

    18

说明/提示

The first test case can be tiled with 44 bricks placed vertically.

The third test case can be tiled with 1818 bricks like this:

首页