A13715 | Bricks
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A brick is defined as a rectangle with integer side lengths with either width $1$ or height $1$ (or both).
There is an $n\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 $5$ bricks. It is possible to do better, using only $4$ bricks. What is the minimum number of bricks required to make a valid tiling?
There is an $n\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 $5$ bricks. It is possible to do better, using only $4$ bricks. What is the minimum number of bricks required to make a valid tiling?
输入格式
The first line contains two integers $n$ , $m$ ( $1\le n, m\le 200$ ) — the number of rows and columns, respectively.
The next $n$ lines describe the grid. The $i$ -th of these lines contains a string of length $m$ , where the $j$ -th character denotes the color of the cell in row $i$ , column $j$ . A black cell is given by "\#", and a white cell is given by ".".
It is guaranteed that there is at least one black cell.
The next $n$ lines describe the grid. The $i$ -th of these lines contains a string of length $m$ , where the $j$ -th character denotes the color of the cell in row $i$ , column $j$ . 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 $4$ bricks placed vertically.
The third test case can be tiled with $18$ bricks like this:

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

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted