I recently looked at the billing flow to find a suitable imitationProgramLooking at the materials, I think it is simpler than the biggest stream for beginners (of course, the level is different from that of four months ago). The basic idea is to pay for the edge and use the shortest circuit.AlgorithmFind the path for increasing the minimum cost. The main program is a bit similar to the ek algorithm of the largest stream, and it uses spfa to find the minimum cost and add light to the base. It is also a very familiar algorithm. After imitating one program, I typed one program myself. The second program was completed in 12 minutes. However, after debugging for a long time, both programs encountered variable errors or a low-level error of missing statements ......
If you have time, you need to study the best Binary Graph Matching, zkw, and other algorithms. Familiarize yourself with modeling, linear programming of parameters, and 24 questions about network flow. Then, find some classic questions, the basic network flow should not be a problem.
With the minimum fee flow program:
Const OO = 19930508; var Dist, path: array [0 .. 1000] of longint; F, cost: array [0 .. 1000, 0 .. 1000] of longint; I, J, K, M, N, X: longint; maxflow, mincost, flow: longint; Q: array [0 .. 100000] of longint; flag: array [0 .. 10000] of Boolean; Head, tail: longint; now, pre: longint; S, T: longint; y, z, W: longint; function min (A, B: longint): longint; begin If A <B then exit () Else Exit (B); end; function spfa: Boolean; begin fillchar (flag,Sizeof (FLAG), 0 ); For I: = 1 to n Do Dist [I]: = Oo; head: = 0; tail: = 1; Q [1]: = s; flag [s]: = True ; Dist [s]: = 0; While Head <tail Do Begin Inc (head); I: = Q [head]; flag [I]: = False ; For J: = 1 to n Do If (F [I, j]> 0) and (Dist [J]> Dist [I] + cost [I, j]) then begin Dist [J]: = DIST [I] + cost [I, j]; path [J]: = I; If Not flag [J] Then begin Inc (tail); Q [tail]: = J; flag [J]: = True ; End; exit (Dist [T] <> OO); end; Procedure Init; begin readln (n, m ); For I: = 1 to n Do Begin For J: = 1 to n Do Cost [I, j]: = Oo; cost [I, I]: = 0; end; For I: = 1 to m Do Begin readln (X, Y, Z, W); F [x, y]: = z; cost [x, y]: = W; end; s: = 1; t: = N; end; Procedure main; begin While Spfa Do Begin now: = T; flow: = Oo; While Now <> S Do Begin pre: = path [now]; flow: = min (flow, F [pre, now]); now: = pre; end; Inc (maxflow, flow); now: = T; While Now <> S Do Begin pre: = path [now]; Dec (F [pre, now], flow); Inc (F [now, pre], flow); cost [now, pre]: =-cost [pre, now]; mincost: = mincost + cost [pre, now] * flow; now: = pre; end; Procedure print; begin writeln (mincost); end; begin assign (input, 'Data. in' ); Reset (input); assign (output, 'Data. out' ); Rewrite (output); Init; main; print; close (input); close (output); end.