<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; } // do{ memset(vis, 0, sizeof(vis)); } while(dfs(n, n + 1, 2000000000)); </Verbatim> * Set ALLOWTOPICCHANGE = MatthewChan, YuryKholondyrev, SapphireJay
This topic: Main
>
ProgrammingContest
>
Code_MaximumFlowShort
Topic revision: r3 - 2005-11-18 - MatthewChan
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