博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(最小点覆盖) poj 2226
阅读量:4324 次
发布时间:2019-06-06

本文共 1864 字,大约阅读时间需要 6 分钟。

H - Muddy Fields
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
Submit     

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.

 

 建图是关键
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;char s[55][55];int n,m,t1,t2,g1[55][55],g2[55][55],mp[1010][1010],ans,link[1010],mark[1010];void init(){ t1=0,t2=0; for(int i=0;i

  

转载于:https://www.cnblogs.com/water-full/p/4460953.html

你可能感兴趣的文章
redis desktop manager连接远程linux中的Redis
查看>>
POJ刷题计划
查看>>
css3 背景透明
查看>>
Android适配API23之后权限的动态申请
查看>>
[operator]ELK6 index pattern的问题
查看>>
Zabbix监控DB,Tomcat
查看>>
Python学习(2 数据运算)
查看>>
87.在ModelSim中添加Xilinx ISE仿真库
查看>>
配置django项目总结 + 思维导图
查看>>
xadmin后台管理
查看>>
GO -- 一个经验
查看>>
CI框架在 nginx 服务器上配置 rewrite 去掉 index.php 的方法:
查看>>
《每日一博》——学习php
查看>>
custom.js
查看>>
Centos 7 中 QT出现QSqlDatabase: MYSQL driver not loaded
查看>>
在 IBM RAD 平台上基于 JAX-WS 开发 Web Services服务器端,客户端
查看>>
利用forwardInvocation实现消息重定向
查看>>
自定义维度与指标
查看>>
跟我一起玩Win32开发(13):握手对话框
查看>>
C#调用C/C++动态库 封送结构体,结构体数组
查看>>