We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 856c79d + b277628 commit aaaf8bcCopy full SHA for aaaf8bc
atcoder/maxflow.hpp
@@ -99,8 +99,9 @@ template <class Cap> struct mf_graph {
99
g[v][i].cap += d;
100
g[e.to][e.rev].cap -= d;
101
res += d;
102
- if (res == up) break;
+ if (res == up) return res;
103
}
104
+ level[v] = _n;
105
return res;
106
};
107
@@ -109,11 +110,9 @@ template <class Cap> struct mf_graph {
109
110
bfs();
111
if (level[t] == -1) break;
112
std::fill(iter.begin(), iter.end(), 0);
- while (flow < flow_limit) {
113
- Cap f = dfs(dfs, t, flow_limit - flow);
114
- if (!f) break;
115
- flow += f;
116
- }
+ Cap f = dfs(dfs, t, flow_limit - flow);
+ if (!f) break;
+ flow += f;
117
118
return flow;
119
0 commit comments