1源程序清单第一章 算法核心功能代码1.1 网络流运行过程代码1.void add(int a, int b, int c, int d) {2. e[idx] = b, f[idx] = c, w[idx] = d, ne[idx] = h[a], h[a] = idx ++;3. e[idx] = a, f[idx] = 0, w[idx] =-d, ne[idx] = h[b], h[b] = idx ++;4.}5.bool SPFA(void) //用 SPFA 代替 BFS6.{7. std::queue q;8. std::memset(dis, 0x3f, sizeof dis);9. q.emplace(S);10. dis[S] = 0;11. cur[S] = h[S];12. while (q.size()) {13. int u = q.front(); q.pop();14. vis[u] = 0;15. fo...
发表评论取消回复