【HDU4307】Matrix

This blog is basically transferred from https://www.cnblogs.com/staginner/archive/2012/08/13/2636826.html, too strong ORZ

meaning of the title

  A is a 1*n matrix, each element is 1 or 0, you need to construct a matrix A such that D=(A*BC)*AT is the largest, where B is a given n*n matrix, C is a given The resulting 1*n matrices, their elements are all non-negative. output the largest D.

analyze

       Essentially, the key to being able to use maximum flow to solve this problem is that maximum flow can solve the minimum of the following function:

    

    

   Next, we will analyze how to use the maximum flow to solve the extremum of the above function.

 

    First of all, there are only two choices for xi, so in the end, xi can be divided into two sets according to the value of xi, then if xi is in the set with a value of 1, and xj is in a set with a value of 0, then there will be a cost cij. At the same time, if xi chooses 0, there will be a cost of bi, and if xi chooses 1, there will be a cost of ai.

 

    Therefore, a source point S is constructed, and the sink point T is the minimum cut. It may be assumed that the set of xi with a value of 1 after the minimum cut is the part connected to S, and the set of xi with a value of 0 is the part connected to T.

 

    Since there are three terms in the expression, we use three cut edges to describe the values ​​of these three terms. One is that xi chooses 1, so that 0 cannot be selected, and the edge xi-T needs to be cut off. Since choosing 1 for xi will incur the cost of ai, then the capacity of this edge is set to ai. The other is that xi chooses 0, so that 1 cannot be selected, and the edge S-xi needs to be cut off. Since choosing 0 for xi will result in the cost of bi, then the capacity of this edge is set to bi. The last one is that xi chooses 1 and xj chooses 0, so that xi and xj cannot be in the same set, and the edge xi-xj needs to be cut off. Since xi chooses 1 and xj chooses 0 to generate the cost of cij, then Let the capacity of this edge be set to cij.

 

    In this way, the minimum cut of the built graph can be used to obtain the minimum value of which function above.

-------------------------------------------------- --------------------- I am the dividing line ------------------------- -------------------------------------------------- -----------------------

   Then we return to the original question and find a way to transform in the direction of the above formula.

   The calculation for this question is written like this

 

 

  

  Then you can solve this problem through the network flow according to the above method.

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325254159&siteId=291194637