<Verbatim> int dfs(int now, int goal, int mx){ // max flow if(now == goal) return mx; vis[now] = 1; int temp; for(int i = 0; i < n + 2; i++) if(!vis[i] && flo[now][i] < cap[now][i]) if((temp = dfs(i, goal, mx <? (cap[now][i] - flo[now][i])))) { flo[now][i] += temp, flo[i][now] -= temp; return temp; } return 0; } // usage: do{ memset(vis, 0, sizeof(vis)); } while(dfs(n, n + 1, 1000000)); </Verbatim> ------ * Set ALLOWTOPICCHANGE = MatthewChan, YuryKholondyrev
This topic: Main
>
ProgrammingContest
>
MaximumFlow
Topic revision: r1 - 2005-11-17 - YuryKholondyrev
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback