POJ Muddy Fields 泥泞的牧场 二分图

Muddy Fields
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 13235   Accepted: 4879

汪星人语言:

Description

Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, the rain makes some patches of bare earth quite muddy. The cows, being meticulous grazers, don't want to get their hooves dirty while they eat.

To prevent those muddy hooves, Farmer John will place a number of wooden boards over the muddy parts of the cows' field. Each of the boards is 1 unit wide, and can be any length long. Each board must be aligned parallel to one of the sides of the field.

Farmer John wishes to minimize the number of boards needed to cover the muddy spots, some of which might require more than one board to cover. The boards may not cover any grass and deprive the cows of grazing area but they can overlap each other.

Compute the minimum number of boards FJ requires to cover all the mud in the field.

Input

* Line 1: Two space-separated integers: R and C

* Lines 2..R+1: Each line contains a string of C characters, with '*' representing a muddy patch, and '.' representing a grassy patch. No spaces are present.

Output

* Line 1: A single integer representing the number of boards FJ needs.

Sample Input

4 4
*.*.
.***
***.
..*.

Sample Output

4

Hint

OUTPUT DETAILS:

Boards 1, 2, 3 and 4 are placed as follows: 
1.2. 
.333 
444. 
..2. 
Board 2 overlaps boards 3 and 4.

Source

喵星人语言(本人英语不好QAQ)

大雨侵袭了奶牛们的牧场.牧场是一个R * C的矩形,其中1≤R,C≤50.大雨将没有长草的土地弄得泥泞不堪,可是小心的奶牛们不想在吃草的时候弄脏她们的蹄子. 为了防止她们的蹄子被弄脏,约翰决定在泥泞的牧场里放置一些木板.每一块木板的宽度为1个单位,长度任意.每一个板必须放置在平行于牧场的泥地里. 约翰想使用最少的木板覆盖所有的泥地.一个木板可以重叠在另一个木板上,但是不能放在草地上.

第1行:两个整数R和C. 
第2到R+1行:每行C个字符,其中“*’代表泥地,“.”代表草地.

POJ Muddy Fields 泥泞的牧场 二分图

不能盖住好地,那么宽为1的木板只能放在行、列连通块里。

所以行、列连通块对应左、右部中的点,泥地对应边。

求二分图最小覆盖就是答案。

也就是说二分图的左边存的是横着的泥泞段  右边存的竖着的泥泞段

如果有交点就连上一条边那么求最小覆盖  看起来很简单的样子

代码如下:

上一篇:iview框架下,modal内容过长,select选项位置不对


下一篇:「CF1227F2」题解