I found a lot of information andProgramMost of them are inconsistent with the programming style and language. Finally, I got a little bit clear. Because there are a lot of unfeasible arcs when we look for them, and they are still unfeasible before the distance label is modified, we introduce the cur array to mark the first viable arc, modify the distance label every time. According to this: "I have heard that the current arc is optimized, but I added it to myself.CodeError. The reason was finally found, because some operations to update the distance label were previously completed when finding a feasible arc, but this would cause problems. After the operation is independent, the problem is solved. "And another great Bull program seems like this. So I didn't continue to think about it when I was lazy. I integrated this idea into my own code and submitted the largest bare stream, AC. The program should be okay.
Refer:
Http://baike.dangzhi.com/wiki/SAP#SAP.E7. AE .97.E6.B3.95
Http://hi.baidu.com/lemon_workshop/blog/item/ab28ecbc71717d0718d81f15.html
Http://dementrock.ixiezi.com/2010/07/28/noi-2006-%E6%9C%80%E5%A4%A7%E8%8E%B7%E5%88%A9/
I think there should be very few questions that can be stuck in SAP + gap + cur programs ......
Appendix: My rqnoj194 Program
Const OO = 19930508; var C: array [0 .. 1000, 0 .. 1000] of longint; H, FLAC, cur: array [0 .. 1000] of longint; maxflow, n, m, I, J, K, x, y, z: longint; function Aug (I, now: longint): longint; var K, minh, TMP, J: longint; begin Aug: = 0; Minh: = n-1; If I = n then begin Inc (maxflow, now); exit (now); end; For J: = 1 to n Do If C [I, j]> 0 then begin If H [J] = H [I]-1 then begin If C [I, j]> now then TMP: = Aug (J, now) Else TMP: = Aug (J, C [I, j]); Dec (C [I, j], TMP); Inc (C [J, I], TMP ); dec (now, TMP); Inc (Aug, TMP ); If H [1]> = n then exit; If Now = 0 then Break ; End; If Aug = 0 then begin For J: = 1 to n Do If (C [I, j]> 0) and (H [J] <Minh) then begin Minh: = H [J]; K: = J; end; cur [I]: = K; // Cur Optimization Dec (successively [H [I]); If * H [H [I] <= 0 Then H [1]: = N; H [I]: = Minh + 1; Inc (* H [I]); end; end; Procedure sap; begin fillchar (VH, Sizeof (VL), 0); fillchar (H, Sizeof (H), 0); FLAC [0]: = N; For I: = 1 to n Do Cur [I]: = 1; // Initialize the Current Arc While H [1] <n Do Aug (1, OO); end; begin readln (m, n ); For I: = 1 to m Do Begin readln (x, y, z); C [x, y]: = z; end; sap; writeln (maxflow); end.