Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ch9/mcmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ class min_cost_max_flow {
if (!directed) add_edge(v, u, w, c); // add again in reverse
}

pair<ll, ll> mcmf(int s, int t) {
pair<ll, ll> mcmf(int s, int t, ll flow_limit = (ll)1e18) {
ll mf = 0; // mf stands for max_flow
while (SPFA(s, t)) { // an O(V^2*E) algorithm
while (SPFA(s, t) && mf < flow_limit) { // an O(V^2*E) algorithm
last.assign(V, 0); // important speedup
while (ll f = DFS(s, t)) // exhaust blocking flow
while (ll f = DFS(s, t, flow_limit - f)) // exhaust blocking flow
mf += f;
}
return {mf, total_cost};
Expand Down