[Minimum path overlay, binary graph maximum match] Pku3020--antenna Placement

Source: Internet
Author: User
Tags first row

http://acm.pku.edu.cn/JudgeOnline/problem?id=3020

Antenna Placement

Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 2319 Accepted: 1082

Description The Global aerial Centre has been allotted the task of building the fifth generation of mobile phone Nets in Sweden. The most striking reason so they got the job, is their discovery of a new, highly noise resistant, antenna. It's called 4DAir, and comes in four types. Each type can is transmit and receive signals in a direction aligned with a (slightly skewed) latitudinal and Longitudin Al 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 a example picture of places of interest, depicted by twelve small rings, and nine 4DAir antennas depicted by ell Ipses covering them.

Obviously, it is desirable to use as few antennas as possible, but still provide coverages for each place of interest. We model The problem as follows:let A is a rectangular matrix describing the surface of Sweden, where an entry of a eithe R is a point of interest, which must are covered by at least one antenna, or empty space. Antennas can only is positioned at the entry in A. When an antenna was placed at row R and column C, this entry was considered covered, but also one of the neighbouring Entrie S (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's the least number of antennas for which there exists a placement in a such so all points of interest are covered?

Input on the first row of input was a single positive integer n and specifying the number of scenarios that follow. Each scenario begins with a row containing the positive integers h and W, with 1 <= h <= 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 CH Aracters 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 Matri x, on a row of its own.

Sample Input

2
7 9
ooo**oooo
**oo*ooo*
o*oo**o**
ooooooooo
*******oo
o*o*oo*oo
*******oo
1 * * *
o
*
* * * * * *

Sample Output

5

Source Svenskt mästerskap I programmering/norgesmesterskapet 2001

The main topic: On a n*m board, there are some signs, ask at least how many 1*2 rectangles can put them all to cover.

Analysis: The classic maximum matching problem. For all signs, the 1*2 can be used to cover two signs with a rectangle, forming a two-part graph. The original problem is converted to the minimum path coverage. Minimum path coverage = number of vertices-maximum number of matches. If you have a double-sided edge, you must div2 the maximum number of matches to be reduced.

Codes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.