Spoj Optimal Marks (Application of minimum cut) really good problem, network flow is almost everywhere, can solve some seemingly difficult problems, hoping to learn from its essence-model building + build map Test instructions:
Given an val[u graph, each vertex has a corresponding value, each edge has a weight of [] ^ val[u], and at the same time it is known that the value of some of the points, the weight of the other points so that the final figure Benquan and minimum?
Analysis:
First the edge and edge are different or manipulated, not very good direct processing, because the XOR operation each of the operation is independent, we come to the point of view, then for those unknown weight points, this bit is either 0, or 1, and we also have to pay attention to the edge of the two endpoints of the same value is not a weight, that is 0, and the difference is the weight of 1, And our goal is to minimize the edge and, in this way, we can think of the problem is equivalent to: The point set is divided into two parts point set is 0-1, the minimum number of edges need to be deleted, and these need to delete the edge is we have to put its two ends of the value of the different side, while the other edge weights 0, because the only In order to make the deletion of the edge of the smallest, also known as the right edge and the smallest, I believe this explanation is easier to understand!
If the thinking process for this model transformation is not yet understood, it is recommended to draw a diagram with an example to understand it!
The rest is to build the side, currently considering the first i Bits, for some known points, by the source point S With a point with the corresponding bit 0, the weighted value i n F , the point with the corresponding bit 1 is connected with the meeting point, and the weight value is i n F , last Run maximum flow m a x f l o Span style= "Font-family:mathjax_math; font-style:italic; "id=" mathjax-span-2199 "class=" Mi ">w Just the right value. aNs+= ∑ i=0 31 2 i ?M axF Lo w i
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Spoj Optimal Marks (Application of Minimum cut)