
网路流
几许情愁
这个作者很懒,什么都没留下…
展开
-
牛客练习赛53 D 德育分博弈政治课 【网络流+思路】
题目链接:https://ac.nowcoder.com/acm/contest/1114/D;思路:骰子总共只有C( 9,6 ) 就是84种,建立超级源点,源点和每个骰子连边,流量为同一种类骰子的个数,每个骰子和1,2,3……8,9连边,最后把询问序列和1,2,3……8,9连边,跑网络流。代码有解释:#include<bits/stdc++.h>using names...原创 2019-10-12 16:29:59 · 242 阅读 · 0 评论 -
[CQOI2012]交换棋子 【费用流】
题目链接:https://www.luogu.org/problem/P3159;思路:这个题最难的地方在于建图;图是有黑点和白点构成,我们只考虑黑点的移动就行。对于一个黑点,如果他向相邻的点移动,就相当于两个点的交换次数都减一;对于一个当前点,可能有其他的点交换到当前点,也可能是当前点交换到其他的点,所以,我们可以把一个点拆成三个点(a,b,c);如果有其他点交换到当前点,假...原创 2019-09-12 10:11:59 · 196 阅读 · 0 评论 -
hdu 6582 19 航电多校第一场1005题 path 【最短路+最小割】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6582/*思路:最短路径构成的图的最小割(即最大流)最短路径图:spaf得到 1 到所有点的单源最短路(dis),再求出 n 到所有点的单源最短路(dis1)遍历每条路,设当前边起点为 u ,终点为 v ,圈主为 w , 如果 dis[u]+dis1[v]+w==1到n的最短路径那么...原创 2019-07-26 17:14:05 · 188 阅读 · 0 评论 -
hdu 4612 Warm up【缩点+求树的直径+tarjan求割桥】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4612Problem Description N planets are connected by M bidirectional channels that allow instant transportation. It's always possible to travel between...原创 2018-11-13 21:11:45 · 183 阅读 · 0 评论 -
poj 2516 Minimum Cost【最大流最小费用流】
题目链接:http://poj.org/problem?id=2516;题目大意:有 n 个商店,m 个仓库,k 种商品,问满足供货商要求的最小花费是多少,如果不能满足输出-1;前 n 行为每个商店需要商品的数量,接着 m 行为每个仓库能放的多少个每种商品,然后是 k 个 n*m 的矩阵,表示第 k 个物品从仓库 i 到商店 j 的花费:思路:每种商品求一下最小费用流,求k次;我的代码...原创 2018-11-05 20:06:30 · 214 阅读 · 0 评论 -
最大流最小费用流模板
struct node{ int v,f,cos,ne;}edge[N*N*2];int head[N],pre[N],dist[N];//head[]为每个变得下标,pre[]用来记录前驱,dist[]最短路时的距离数组bool spaf_vis[N];//最短路的标记数组int s,t,e;void add_insert(int a,int b,int c,int d...原创 2018-11-05 15:42:41 · 216 阅读 · 0 评论 -
hdu 1553 Going Home【最大流最小费用流】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1533题意:给一个 n*m 的地图,上面有数量相同的人和房子,人每走一格需要花费一块前,问全部人走到房子里的最小花费;思路:用网络流 最大流最小费用流求解,让全部人连接超级源点,全部房子连接超级汇点,边的容量唯 1 ,花费可以用bfs求;#include<cstring>#i...原创 2018-11-05 15:40:31 · 204 阅读 · 0 评论 -
UVA 10480 Sabotage 【最大流最小割】
SabotageThe regime of a small but wealthy dictatorship has been abruptly overthrown by an unexpected rebellion. Because of the enormous disturbances this is causing in world economy, an imperialist ...原创 2018-11-07 21:11:54 · 170 阅读 · 0 评论 -
hdu 4280 Island Transport【网路流 dinic模板】
In the vast waters far far away, there are many islands. People are living on the islands, and all the transport among the islands relies on the ships. You have a transportation company there. Som...原创 2018-11-02 20:06:03 · 167 阅读 · 0 评论 -
ACM Computer Factory【网络流dinic+题意理解】
DescriptionAs you know, all the computers used for ACM contests must be identical, so the participants compete on equal terms. That is why all these computers are historically produced at the same f...原创 2018-10-30 20:16:52 · 558 阅读 · 0 评论 -
hdu 3605 Escape【网路流+状态压缩】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3605有n个人要移居m个星球,给出每个合适的星球,每个星球最多能容纳的人数,问是否所有人都可以移居。(1≤N≤105,1≤M≤10)(1≤N≤105,1≤M≤10) 最多有十个星球,而N很大,所以可能会有很多重复,因为每个人去哪个星球最多有2^10中情况,所以可以压缩点,把情况相同的人放到...原创 2018-10-24 20:17:23 · 165 阅读 · 0 评论 -
Flow Problem 【网路流 最大流模板】
Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 15036 Accepted Submission(s): 7092Problem Description Network flow is a well-known difficult p...原创 2018-10-24 10:13:24 · 258 阅读 · 0 评论