[CODEVS1915] 分配问题(最小费用最大流)


传送门

脑残题

建图都懒得说了

——代码

1 #include <queue> 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #define N 1000001 6 #define min(x, y) ((x) < (y) ? (x) : (y)) 7 8 int n, cnt, s, t; 9 int a[101][101], dis[N], pre[N]; 10 int head[N], to[N << 1], val[N << 1], cost[N << 1], next[N << 1]; 11 bool vis[N]; 12 13 inline int read() 14 21 22 inline void add(int x, int y, int z, int c) 23 30 31 inline bool spfa() 32 56 } 57 } 58 } 59 return pre[t] ^ 1; 60 } 61 62 inline int dinic() 74 sum += dis[t] * d; 75 } 76 return sum; 77 } 78 79 int main() 80 97 } 98 printf("%d\n", dinic()); 99 cnt = 0; 100 memset(head, 1, sizeof(head)); 101 for(i = 1; i <= n; i++) 102 112 } 113 printf("%d\n", dinic()); 114 return 0; 115 }
View Code



上一篇:[POJ2912]Rochambeau(并查集)

下一篇:[TyvjP1515] 子串统计 [luoguP2408] 不同子串个数(后缀数组)


最小费用最大流 网络流
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图