POJ 3020 Antenna Placement (bipartite graph creation training + minimum path coverage)

Source: Internet
Author: User

POJ 3020 Antenna Placement (bipartite graph creation training + minimum path coverage)

 

 

 

 

Antenna Placement
Time Limit:1000 MS   Memory Limit:65536 K
Total Submissions:6692   Accepted:3325

 

Description

The Global Aerial Research Centre has been allotted the task of building the maximum th 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 4 DAir, 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 4 DAir antennas depicted by ellipses covering them.

 

 

Question: Given a map, * represents a city, and o represents an open space. The antenna is used to cover two adjacent cities. How many antennas do I need at least? (The so-called adjacent refers to the top, bottom, and left adjacent to Four Directions)

 

The meaning of the question is very clear. Find the minimum path coverage of the Bipartite Graph. The difficulty is to build the graph... Good luck today. The idea of creating a graph comes from ZOJ1654.

PS. It covers the city, not the open space. At first, I was wrong.

 

Ideas: Today, ZOJ 1654, which is about the same as 1654, uses the block-based idea. This idea uses a single city as a block and numbers it to build graph connectivity, as for the final output result, the total number of cities minus the maximum number of matching = the number of remaining cities, that is, the maximum number of independent sets. The number of remaining cities indicates that they cannot be augmented/matched, then we need to build an antenna separately, and the matching number/2 = one antenna covers two cities

So eventually answer = city-ans + ans/2

 

ZOJ 1654 AC code

 

 

Accepted 1584 K 16 MS C ++

 

If you want to understand it, open it and try again, 1A

 

 

# Include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Include
     
      
# Define init (a) memset (a, 0, sizeof (a) # define PI acos (-1, 0) using namespace std; const int maxn = 60; const int maxm = 600; # define lson left, m, id <1 # define rson m + 1, right, id <1 | 1 # define min (a, B) (a> B )? B: a # define max (a, B) (a> B )? A: bint ma [maxn] [maxn]; char MAP [maxn] [maxn]; int G [maxm] [maxm]; int line [maxm]; bool vis [maxm]; int mv [4] [2] = {}, {-}, {}, {0,-1}; int n, m, city; int DFS (int u) {for (int v = 1; v <= city; v ++) {if (G [u] [v] = 1 &&! Vis [v]) {vis [v] = 1; if (line [v] =-1 | DFS (line [v]) {line [v] = u; return 1 ;}} return 0 ;}int K_M () {int ans = 0; memset (line,-1, sizeof (line); for (int I = 1; I <= city; I ++) {init (vis); ans + = DFS (I );} return ans;} void Get_G (int I, int j) // figure {for (int dir = 0; dir <4; dir ++) {int wx = I + mv [dir] [0]; int wy = j + mv [dir] [1]; if (MAP [wx] [wy] = '*') {G [ma [I] [j] [ma [wx] [wy] = 1; // build a connection between the current city and its four adjacent cities }}} Int main () {int t; scanf (% d, & t); char a [500]; while (t --) {scanf (% d, & n, & m); city = 0; gets (a); // The test data cannot be read ..... I am particularly speechless init (ma); init (G); for (int I = 0; I
      
       

 

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.