(重)POJ 3020Antenna Placement
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的更多相关文章
- poj 3020Antenna Placement
http://poj.org/problem?id=3020 #include<cstdio> #include<cstring> #include<algorithm& ...
- POJ:3020-Antenna Placement(二分图的最小路径覆盖)
原题传送:http://poj.org/problem?id=3020 Antenna Placement Time Limit: 1000MS Memory Limit: 65536K Descri ...
- poj 3020 Antenna Placement(最小路径覆盖 + 构图)
http://poj.org/problem?id=3020 Antenna Placement Time Limit: 1000MS Memory Limit: 65536K Total Sub ...
- 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: ...
- (poj)3020 Antenna Placement 匹配
题目链接 : http://poj.org/problem?id=3020 Description The Global Aerial Research Centre has been allotte ...
- POJ 1170 Shopping Offers -- 动态规划(虐心的六重循环啊!!!)
题目地址:http://poj.org/problem?id=1170 Description In a shop each kind of product has a price. For exam ...
- 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 ...
- POJ 1475 Pushing Boxes 搜索- 两重BFS
题目地址: http://poj.org/problem?id=1475 两重BFS就行了,第一重是搜索箱子,第二重搜索人能不能到达推箱子的地方. AC代码: #include <iostrea ...
- POJ 3020 Antenna Placement【二分匹配——最小路径覆盖】
链接: http://poj.org/problem?id=3020 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...
随机推荐
- Xilinx 网站资源导读2
Xilinx 网站资源导读 ———版权声明———–本文作者 Ricky Suwww.fpganotes.comrickysu.fpga@gmail.com 欢迎转载,转载请保持原样及署名商业使用须得到 ...
- smarty实现缓存
首先需要在mySmarty中添加配置信息,开启缓存,设置缓存文件存放目录,设置缓存时间缓存可以实现减少访问数据库,减轻数据库压力,访问一次数据库,形成静态页面,下次直接调用这个页面,也可以用nocac ...
- viewpager双层嵌套,子viewpager无限循环无法手动滑动
项目中首页是用viewpager+fragment集成的,第一个fragment有广告轮播图使用viewpager实现的,开始就遇到是广告图无法手动滑动,事件被外层的viewpager拦截响应切换到下 ...
- kettle中Get Data from XML , Jason Input , 文本文件输入 使用示例
1.Get Data from XML xml文件内容: <head> <img id="1">菜||焦溜丸子||2013-03-28/image/0/00 ...
- JAVA操作LDAP总结
一.LDAP概念 LDAP的全称为Lightweight Directory Access Protocol(轻量级目录访问协议), 基于X.500标准, 支持 TCP/IP. LDAP目录为数据库, ...
- IOS的segmentedControl(分段器控件)的一些常用属性
#pragma mark - 创建不同的分段器 //初始化方法:传入的数组可以是字符串也可以是UIImage对象的图片数组 UISegmentedControl *mysegmented = [[UI ...
- Google 常用镜像收集
1`下面列出几个目前常用的 公共DNS 服务器地址: 名称 DNS 服务器 IP 地址 OpenerDNS 42.120.21.30 百度 DuDNS 180.76.76.76 阿里 AliD ...
- JavaScript基础-对象<2>
2.浏览器环境提供对象 (1) document对象 doucument对象属性: title:文本标题.doucument.title="Welcome"; lastModifi ...
- java中进制之间的转换
//十进制转其他进制 Integer.toHexString(10); //将10转换为十六进制,返回字符串类型 Integer.toOctalString(10); //将10转为八进制,返回字符串 ...
- 14_CXF发布REST服务
[rest服务] REST服务是一种软件架构模式,只是一种风格.REST服务采用HTTP做传输协议. REST对于HTTP的利用分为以下两种: 一.资源定位 REST要求对方资源定位更加准确,如下: ...