Spoj Optimal Marks (Application of Minimum cut)

Source: Internet
Author: User

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)

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.