Topic Links:
https://www.luogu.org/problem/show?pid=3381
Main topic:
Maximum flow and cost flow
Topic Ideas:
Minimum cost maximum flow template questions, notes are marked in the template.
Code:
#include
P3381 "template" Minimum cost maximum flow topic descriptionTitle, a network diagram is given, along with its source and sink points, each edge is known for its maximum flow rate and unit traffic cost, and the minimum cost of its maximum flow and maximum flow is calculated.Input/output formatInput format:The first line
PHPTPL is a lightweight php template engine. No need to learn the cost can be easily mastered, concise is the United States.
PHPTPL is a lightweight php template engine. No need to learn the cost can be easily mastered, concise is the United States.
Recently wanted to write a project management platform, originally wa
Split each point into the origin A and pseudo point b,a->b there are two one-way (adjacency table implementation needs to establish a reverse empty edge, and to ensure that the loop cost and 0), a residual capacity of 1, the cost of its own negative value (easy to calculate the shortest path), the other residual capacity +∞, the cost is 0 ( The point is guarantee
Compared to the maximum flow template: Maximum flow template (Dinic)Paste the minimum fee flow template:const int OO=1E9;CONST int Mm=11111111;const int mn=888888;int node,src,dest,edge;int ver[mm],flow[mm],cost[mm],nex[ Mm];int head[mn],dis[mn],p[mn],q[mn],vis[mn];/** These variables are basically the same as the maximum flow, which increases the
Label: style blog HTTP color Io OS AR for SP
Hmm ~ The first write cost flow question...
This is the template Question of the billing flow. No more bare questions can be found.
Graph creation: Each m (man) serves as the source point, each H (house) serves as the sink point, and each source point and sink point connects one edge separately, the traffic on this edge is 1 (because each source point can only ta
mentioned above, only two-dimensional arrays can be used: when each item can only be retrieved once, the V and U variables adopt a backward loop, when an item is like a full backpack, use a sequential loop. Split an item when there are multiple backpack problems.
You may have some ideas here, so you should be able to understand the two-dimensional cost backpack with a look at the code.
First, let's look at the complete backpack
(Heu step 6.1.1) Constructing Roads (Minimum Spanning Tree template question: Minimum Cost for connecting n points), heuconstructing
Question:
Constructing Roads
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 207 Accepted Submission (s): 135
Problem DescriptionThere are N versions, which are numbered from
Sample Output179
Sourcekicc
Recommendeddy
Topic Analysis:Kruscal minimum spanning tree, simple problem. You need to be aware of the following situations:1) Some roads have been repaired by the way: the weight of the edge of the bar is set to 0.MAP[A][B] = Map[b][a] = 0;//for an already existing edge, we set his weight to 0.2) The connection information is converted from a matrix into an edge form.int cnt = 1;for (i = 1; I for (j
(e[i].c>0) and(dis[q[h]]+e[i].w then * begin $dis[e[i].t]:=dis[q[h]]+e[i].w;Panax Notoginsengfrv[e[i].t]:=q[h];fre[e[i].t]:=i; - if notinq[e[i].t] then the begin +Inc (t);ifT> the thent:=1; aq[t]:=e[i].t;inq[e[i].t]:=true; the End; + End; -i:=e[i].next; $ End; $inq[q[h]]:=false; - End; - End; the begin -Assign (input,'r.in'); Assign (output,'R.out'); reset (input); rewrite
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.