"Network Flow 24 Questions"----(part, continuous update ...) )

Source: Internet
Author: User

Match the pilot

Match Pilot: Http://cogs.yeefan.us/cogs/problem/problem.php?pid=14
Set up a virtual source point meeting point and then water
code:http://cogs.yeefan.us/cogs/submit/code.php?id=148410

Digital trapezoid

Digital Ladder: http://cogs.yeefan.us/cogs/problem/problem.php?pid=738
Exercises
Rules (1)
Abstract each position in the trapezoid into two points (I.A), (I.B), to create an additional source s sinks T.
1, for each point I from (I.A) to (I.B) to connect a capacity of 1, the cost for the point I the weighted value of the forward side.
2, from S to trapezoid top layer each (I.A) with a capacity of 1, the cost of 0 of the forward edge.
3, from the bottom of the ladder each (I.B) to T with a capacity of 1, the cost of 0 of the forward edge.
4, for each point I and the following two points J, respectively, a line from (I.B) to (J.A) capacity of 1, the cost of 0 of the forward edge.
Maximum cost flow, the cost flow value is the result.
Rules (2)
Consider each position in the trapezoid as a point I, and create an additional source S-sink T.
1, from S to trapezoid top layer each I even a capacity of 1, the cost of 0 of the forward edge.
2, from the bottom of the ladder each I to t even a capacity of infinity, the cost of 0 of the forward edge.
3, for each point I and the following two points J, respectively, a line from I to j capacity of 1, the cost is the point I weight of the forward edge.
Maximum cost flow, the cost flow value is the result.
Rules (3)
Consider each position in the trapezoid as a point I, and create an additional source S-sink T.
1, from S to trapezoid top layer each I even a capacity of 1, the cost of 0 of the forward edge.
2, from the bottom of the ladder each I to t even a capacity of infinity, the cost of 0 of the forward edge.
3, for each point I and the following two points J, respectively, a line from I to j capacity for infinity, the cost is the point I weight of the forward edge.
Maximum cost flow, the cost flow value is the result.
In fact, the second and the third are very good to deal with, is the first some trouble, for this problem, we set up n row point or relatively good writing

code:http://cogs.yeefan.us/cogs/submit/code.php?id=157717

Load Balancing

Load balancing: http://cogs.yeefan.us/cogs/problem/problem.php?pid=741
Exercises
First find out the average value of all warehouse inventory, set the surplus of the first warehouse is a[i],a[i] = The original inventory of the first warehouse-the average stock quantity. Create a binary map that abstracts each warehouse into two nodes Xi and Yi. Add additional source s sinks T.
1, if a[i]>0, from S to Xi with a capacity of a[i], the cost of 0 of the forward edge.
2, if a[i]<0, from Yi to t even a capacity of-a[i], the cost of 0 of the forward edge.
3, each Xi to two adjacent vertex J, from Xi to XJ connecting a capacity of infinity, the cost of 1 of the forward edge, from Xi to YJ a capacity of infinity, the cost of 1 of the forward edge.
The minimum cost flow value is the minimum amount of transport.

code:http://cogs.yeefan.us/cogs/submit/code.php?id=157626

"Network Flow 24 Questions"----(part, continuous update ...) )

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.