POJ 3020
发布日期:2021-06-30 15:31:03 浏览次数:2 分类:技术文章

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

Antenna Placement

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 11061   Accepted: 5439

Description

The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their discovery of a new, highly noise resistant, antenna. It is called 4DAir, and comes in four types. Each type can only transmit and receive signals in a direction aligned with a (slightly skewed) latitudinal and longitudinal grid, because of the interacting electromagnetic field of the earth. The four types correspond to antennas operating in the directions north, west, south, and east, respectively. Below is an example picture of places of interest, depicted by twelve small rings, and nine 4DAir antennas depicted by ellipses covering them. 

 
Obviously, it is desirable to use as few antennas as possible, but still provide coverage for each place of interest. We model the problem as follows: Let A be a rectangular matrix describing the surface of Sweden, where an entry of A either is a point of interest, which must be covered by at least one antenna, or empty space. Antennas can only be positioned at an entry in A. When an antenna is placed at row r and column c, this entry is considered covered, but also one of the neighbouring entries (c+1,r),(c,r+1),(c-1,r), or (c,r-1), is covered depending on the type chosen for this particular antenna. What is the least number of antennas for which there exists a placement in A such that all points of interest are covered? 
 

Input

On the first row of input is a single positive integer n, specifying the number of scenarios that follow. Each scenario begins with a row containing two positive integers h and w, with 1 <= h <= 40 and 0 < w <= 10. Thereafter is a matrix presented, describing the points of interest in Sweden in the form of h lines, each containing w characters from the set ['*','o']. A '*'-character symbolises a point of interest, whereas a 'o'-character represents open space. 

 

Output

For each scenario, output the minimum number of antennas necessary to cover all '*'-entries in the scenario's matrix, on a row of its own.

Sample Input

27 9ooo**oooo**oo*ooo*o*oo**o**ooooooooo*******ooo*o*oo*oo*******oo10 1***o******

Sample Output

175

Source

大致题意:

一个矩形中,有N个城市 * ,现在这n个城市都要覆盖无线,若放置一个基站,那么它至多可以覆盖相邻的两个城市。

问至少放置多少个基站才能使得所有的城市都覆盖无线?

解题思路:

先贴一些常用性质:

对于无向图:

最小点覆盖+最大独立集=顶点个数

最大团=补图的最大独立子集

关系1:给定图G = (V,E)无孤立点,则G的极大点独立集都是G的极小支配集。

关系2:G的点覆盖数 a与点独立集数 b满足: a + b = n。

关系3:G的边覆盖数 a与边独立集数 b满足: a + b = n。(边独立集数即匹配数)

关系3:给定图G = (V,E)无孤立点,|V | = n。M是G的匹配,W是G的边覆盖,则|M|≤|W|,等号成立时M是G的完美匹配而W是G的最小边覆盖。

对于二部图: 

最小点覆盖数 = 最大匹配数

最小路径覆盖 = 顶点数 – 最大(二分)匹配数 / 2;

关于二分图最大匹配,这里讲的很详细http://dsqiu.iteye.com/blog/1689505

关于这道题,其实就是先把“*"看成点,然后看可以覆盖的相邻点,两者相连,接着用上面公式求最小路径覆盖

具体理解过程见

代码:

#include
#include
#include
#include
#define maxnum 405using namespace std;struct Point{ int x,y;};Point point[maxnum];//记录下二分图其中一边的顶点,另一边的顶点也是一样的 int v;int visit[maxnum];//该点是否被访问 int match[maxnum];//该点匹配的点,未被匹配为-1 int path(int u){ for(int i=0;i
>casenum; int h,w; while(casenum--){ memset(match,-1,sizeof(match)); cin>>h>>w;getchar(); char temp;int k=0; for(int i=0;i

 

转载地址:https://joycez.blog.csdn.net/article/details/83064796 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:POJ 1804
下一篇:POJ 2388

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月30日 03时14分03秒