传送门

分析

我们知道对于没有障碍的情况就是将横轴点于纵轴点连边

于是对于这种有障碍的情况我们还是分横轴纵轴考虑

只不过对于有障碍的一整条分为若干个无障碍小段来处理

然后将标号小段连边,跑最大匹配即可

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int n,m,be1[][],be2[][],g[][],Ans,T,used[],belong[];
char s[][];
inline bool work(int x){
for(int i=;i<=m;i++)
if(used[i]!=T&&g[x][i]){
used[i]=T;
if(!belong[i]||work(belong[i])){
belong[i]=x;
return ;
}
}
return ;
}
inline void go(){
for(int i=;i<=n;i++){
T=i;
if(work(i))Ans++;
}
}
int main(){
int w,r,i,j,k;
scanf("%d%d",&w,&r);
for(i=;i<w;i++)
scanf("%s",s[i]);
for(i=;i<w;i++){
k=;
for(j=;j<r;j++){
if(s[i][j]=='.'&&!k)k=;
if(s[i][j]=='*'){
if(k)n++,k=;
be1[i][j]=n;
}
}
}
for(i=;i<r;i++){
k=;
for(j=;j<w;j++){
if(s[j][i]=='.'&&!k)k=;
if(s[j][i]=='*'){
if(k)m++,k=;
be2[j][i]=m;
}
}
}
for(i=;i<w;i++)
for(j=;j<r;j++)
g[be1[i][j]][be2[i][j]]=;
go();
cout<<Ans;
return ;
}

bzoj1735 [Usaco2005 jan]Muddy Fields 泥泞的牧场的更多相关文章

  1. bzoj 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场 最小点覆盖

    链接 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场 思路 这就是个上一篇的稍微麻烦版(是变脸版,其实没麻烦) 用边长为1的模板覆盖地图上的没有长草的土地,不能覆盖草地 ...

  2. BZOJ 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场

    Description 大雨侵袭了奶牛们的牧场.牧场是一个R * C的矩形,其中1≤R,C≤50.大雨将没有长草的土地弄得泥泞不堪,可是小心的奶牛们不想在吃草的时候弄脏她们的蹄子.  为了防止她们的蹄 ...

  3. [Usaco2005 Jan]Muddy Fields泥泞的牧场

    Description 雨连续不断的击打了放牛的牧场,一个R行C列的格子(1<=R<=50,1<=C<=50).虽然这对草来说是件好事,但这却使得一些没有草遮盖的土地变得很泥泞 ...

  4. POJ Muddy Fields 泥泞的牧场 二分图

    Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13235   Accepted: 4879 汪星人 ...

  5. bzoj 1689: [Usaco2005 Open] Muddy roads 泥泞的路

    1689: [Usaco2005 Open] Muddy roads 泥泞的路 Description Farmer John has a problem: the dirt road from hi ...

  6. bzoj1689 / P1589 [Usaco2005 Open] Muddy roads 泥泞的路

    P1589 [Usaco2005 Open] Muddy roads 泥泞的路 简单的模拟题. 给水坑排个序,蓝后贪心放板子. 注意边界细节. #include<iostream> #in ...

  7. bzoj1689 [Usaco2005 Open] Muddy roads 泥泞的路

    Description Farmer John has a problem: the dirt road from his farm to town has suffered in the recen ...

  8. 【BZOJ】1689: [Usaco2005 Open] Muddy roads 泥泞的路(贪心)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1689 一开始我也想到了贪心,,,策略是如果两个连续的水池的距离小于l的话,那么就将他们链接起来,,, ...

  9. [USACO2005][POJ2226]Muddy Fields(二分图最小点覆盖)

    题目:http://poj.org/problem?id=2226 题意:给你一个字符矩阵,每个位置只能有"*"或者“.",连续的横着或者竖的“*"可以用一块木 ...

随机推荐

  1. L124

    I have a toothache because there is a cavity in one of my teeth. I founded an orphanage last year an ...

  2. 1.mysql优化---优化入门之MySQL的优化介绍及执行步骤

    优化到底优化什么?      优化,一直是面试最常问的一个问题.因为从优化的角度,优化的思路,完全可以看出一个人的技术积累.那么,关于系统优化,假设这么个场景,用户反映系统太卡(其实就是高并发),那么 ...

  3. PHP 判断字符的编码 并输出想要的编码格式字符 (转)

    /** * 判断字符编码  并输出想要的编码 * Enter description here ... * @param unknown_type $string * @param unknown_t ...

  4. IDEA中遇到的gradle问题:unindexed remote maven repositories found

    环境公司提供的IDEA,版本为16.3. 前端环境为react.版本控制使用gradle,后端语言使用kotlin. 在项目的依赖导入过程中出现了如下问题: unindexed remote mave ...

  5. hihoCoder1296:约瑟夫问题

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho的班级正在进行班长的选举,他们决定通过一种特殊的方式来选择班长. 首先N个候选人围成一个圈,依次编号为0.. ...

  6. Oracle 12c 搭建学习

    Oracle 12c 搭建学习 Vm workstaton10 安装linux 6.4 安装oracle12c Oracle 12c只支持64位系统 1 环境检查 [root@rac1 ~]# gre ...

  7. Spring学习八

    1: Tomcat容器四个等级? Container, Engine,  Servlet容器, Context 真正管理Servlet的容器是Context容器:一个context对应一个web工程. ...

  8. linux串口基本编程

    Linux的串口表现为设备文件.Linux的串口设备文件命名一般为/dev/ttySn(n=0.1.2„„),若串口是USB扩展的,则串口设备文件命名多为/dev/ttyUSBn(n=0.1.2„„) ...

  9. 最新版CocoaPods的安装流程

    1.移除现有Ruby默认源 $gem sources --remove https://rubygems.org/ 2.使用新的源 $gem sources -a https://ruby.taoba ...

  10. Spring MVC配置详解(1)

    web.xml的配置 <!-- 配置前端控制器 前端控制器(DispatcherServlet)--> <servlet> <servlet-name>spring ...