http://poj.org/problem?id=3020

呃。。。这个题不是很会,所以找了大神的博客做了参考,说得很详细

http://blog.csdn.net/lyy289065406/article/details/6647040

#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std ;
const int maxn = ;
int map[maxn][maxn] ;
int ID ;
int v1,v2 ;
int ma ;
bool city[maxn][maxn] ;
bool vist[maxn] ;
int link[maxn] ;
int dirr[] = {-,,,} ;
int dirc[] = {,,-,} ;
bool dfs(int x)
{
for(int i = ; i <= v2 ; i++)
{
if(city[x][i] && !vist[i])
{
vist[i] = true ;
if(link[i] == || dfs(link[i]))
{
link[i] = x ;
return true ;
}
}
}
return false ;
}
void sea()
{
for(int i = ; i <= v1 ; i++)
{
memset(vist, ,sizeof(vist)) ;
if(dfs(i))
ma++ ;
}
return ;
}
int main()
{
int t ;
scanf("%d",&t) ;
while(t--)
{
memset(map,,sizeof(map)) ;
memset(city,,sizeof(city)) ;
memset(link,,sizeof(link)) ;
ID = ;
ma = ;
int h,w ;
scanf("%d %d",&h,&w) ;
char temp ;
for(int i = ; i <= h ; i++)
{
for(int j = ; j <= w ; j++)
{
cin>>temp ;
if(temp == '*')
map[i][j] = ++ ID ;
}
}
for(int i = ; i <= h ; i++)
{
for(int j = ; j <= w ; j++)
{
if(map[i][j])
{
for(int k = ; k < ; k++)
{
int x = i+dirr[k] ;
int y = j+dirc[k] ;
if(map[x][y])
city[map[i][j]][map[x][y]] = true ;
}
}
}
}
v1 = v2 = ID ;
sea() ;
printf("%d\n",ID-ma/) ;
}
return ;
}

(重)POJ 3020Antenna Placement的更多相关文章

  1. poj 3020Antenna Placement

    http://poj.org/problem?id=3020 #include<cstdio> #include<cstring> #include<algorithm& ...

  2. POJ:3020-Antenna Placement(二分图的最小路径覆盖)

    原题传送:http://poj.org/problem?id=3020 Antenna Placement Time Limit: 1000MS Memory Limit: 65536K Descri ...

  3. poj 3020 Antenna Placement(最小路径覆盖 + 构图)

    http://poj.org/problem?id=3020 Antenna Placement Time Limit: 1000MS   Memory Limit: 65536K Total Sub ...

  4. poj 2762 Going from u to v or from v to u?(强连通分量+缩点重构图+拓扑排序)

    http://poj.org/problem?id=2762 Going from u to v or from v to u? Time Limit: 2000MS   Memory Limit:  ...

  5. (poj)3020 Antenna Placement 匹配

    题目链接 : http://poj.org/problem?id=3020 Description The Global Aerial Research Centre has been allotte ...

  6. POJ 1170 Shopping Offers -- 动态规划(虐心的六重循环啊!!!)

    题目地址:http://poj.org/problem?id=1170 Description In a shop each kind of product has a price. For exam ...

  7. poj 1564 Sum It Up | zoj 1711 | hdu 1548 (dfs + 剪枝 or 判重)

    Sum It Up Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Sub ...

  8. POJ 1475 Pushing Boxes 搜索- 两重BFS

    题目地址: http://poj.org/problem?id=1475 两重BFS就行了,第一重是搜索箱子,第二重搜索人能不能到达推箱子的地方. AC代码: #include <iostrea ...

  9. POJ 3020 Antenna Placement【二分匹配——最小路径覆盖】

    链接: http://poj.org/problem?id=3020 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...

随机推荐

  1. html元素拖拽

    html <div> <div class="money-input"> 定投金额 : <div class="input-rela&quo ...

  2. asp快速开发方法之分页函数

    log_Content "自己常用的ASP分页代码,将以下代码放入你的函数文件内,在使用的文件内写上<!--#include file="调用文件.asp" /&g ...

  3. <转载>国外程序员推荐的免费编程书籍资源

    一.George Stocker 提供了一大串,分类如下: How to Design Programs: An Introduction to Computing and Programming 2 ...

  4. WCF编程系列(二)了解WCF

    WCF编程系列(二)了解WCF   面向服务     服务是复用进化的结果,起初的复用是函数,面向对象编程的出现使复用从函数上升到对象,随后面向组件编程又将复用从对象上升到组件,现在面向服务编程将复用 ...

  5. JAVA远程执行Shell脚本类

    1.java远程执行shell脚本类 package com.test.common.utility; import java.io.IOException; import java.io.Input ...

  6. UIMenuController/UIPasteboard(1) 制作一个可以粘贴复制的Label

    效果如下:   苹果只放出来了 UITextView,UITextField,webView三个控件的剪贴板,所以我们要自定义可以复制粘贴的控件,首先需要打开UIResponder的两个方法: - ( ...

  7. IOS 应用程序启动加载过程(从点击图标到界面显示)

    今天帮同事解决问题的时候发现,程序BUG是由加载过程引起的.所以当局部代码没有问题,但是程序一运行却总不是我们想要结果的时候,我们应该想想是不是因为我们忽略了试图加载过程的原因.下面我们用一个例子来简 ...

  8. FancyBox——jQuery弹出窗口插件

    最近工作项目中有用到这款插件,就查找了一下相关资料和用法,下面是一些基本的简单用法,比较容易掌握,有需要的小伙伴可以参考.:) FancyBox是一款基于jquery开发的类Lightbox插件.支持 ...

  9. hibernate的dao操作不能提交到数据库问题的解决

    刚学的时候总是各种错误,解决方法也无厘头的很 将UserDAO里面的的save方法修改try { getSession().save(transientInstance); log.debug(&qu ...

  10. bzoj1002:[FJOI2007]轮状病毒

    思路:一道很裸的生成树计数问题,然而要高精度,而且听说直接行列式求值会被卡精度,所以可以模拟行列式求值的过程得到递推公式:f[i]=3*f[i-1]-f[i-2]+2,证明详见vfk博客: http: ...