随笔分类 - 网络流
摘要:思路:这题的原型题是比较经典的网络流。原型题模型就是把所有的障碍去掉。有障碍做法还是一样的,只用将每个列和行重新划分,求最大流就行了。#include #include #include #include #define Maxn 120010#define Maxm 210000#define LL int#define inf 100000000#define Abs(a) (a)>0?(a):(-a)using namespace std;struct Edge{ int from,to,next; LL val;}edge[Maxm];const double eps=1e...
阅读全文
摘要:裸的网络流,递归的dinic会爆栈,在第一行加一句就行了#pragma comment(linker, "/STACK:1024000000,1024000000")#include #include #include #include #include #include #define Maxn 120010#define Maxm 210000#define LL int#define inf 100000000#define Abs(a) (a)>0?(a):(-a)using namespace std;struct Edge{ int from,to,nex
阅读全文
摘要:#include #include #include #define Maxn 120010#define Maxm 210000#define LL int#define inf 100000000#define Abs(a) (a)>0?(a):(-a)using namespace std;struct Edge{ int from,to,next; LL val;}edge[Maxm];const double eps=1e-9;LL value[Maxn];int head[Maxn],work[Maxn],dis[Maxn],q[Maxn],e,vi[Maxn];voi...
阅读全文
摘要:思路:这个还是看的胡伯涛的论文《最小割在信息学竞赛中的应用》。是将最大密度子图问题转化为了01分数规划和最小割问题。直接上代码:#include #include #include #include #include #define Maxn 6010#define Maxm 200000#define LL double#define inf 100000000#define Abs(a) (a)>0?(a):(-a)using namespace std;struct Edge{ int from,to,next; LL val;}edge[Maxm];const double...
阅读全文
摘要:思路:这题考的是最大闭权图。只要知道怎么求最大闭权图就知道怎么做。但好像有点卡模版,要高效的模版才行。#include #include #include #define Maxn 6010#define Maxm 200000#define LL __int64#define Abs(a) (a)>0?(a):(-a)using namespace std;struct Edge{ int from,to,next; LL val;}edge[Maxm];LL value[Maxn],inf=0;int index[Maxn],work[Maxn],dis[Maxn],q[Max...
阅读全文
摘要:思路:这题的结论得要看amber的论文,结论就是将求f(x)/b(x)最小转化为求min(f(x)-b(x)*λ),其中x为S集的解空间,f(x)为解的边权和,b(x)为解的边数,λ=f(x)/b(x)。λ*为最优解,当且仅当(x属于S)∑min(f(x)-b(x)*λ)==0;故可以将原边权的权值改为w-λ;对λ进行二分枚举,找出答案。#include#include#include#include#include#define N 510#define M 50010#define inf 1e9using namespace std;const double eps=1e-9;struc
阅读全文
摘要:#include#include#include#include#define N 2000#define M 1000010#define inf 1=n)return flow-lv; if(lv==0) break; } if(d[v]>1; memset(index,-1,sizeof(index)); for(i=1;in)建立一个流量为1的边,从每个人向每个他从属的组织建立一条流量为1的边,在由每个组织建立一条流向汇点的边,我们可以二分枚举组织向汇点边的流量。
阅读全文
摘要:对于网络流有一个定理:最小点权覆盖集=最大网络流;最大点权独立集=总权值-最小点权覆盖集;网络流解法代码如下:#include#include#include#include#define N 1010#define M 50010#define inf 1=n)return flow-lv; if(lv==0) break; } if(d[v]1) addedge(pos(i,j),pos(i-1,j),inf); if(j>1) ...
阅读全文
摘要:递归版sap:#include#include#include#include#define N 310#define M 50010#define inf 1=n)return flow-lv; if(lv==0) break; } if(d[v]#include#include#include#include#define Maxn 6010#define Maxm 200000#define LL __int64#define Abs(a) (a)>0?(a):(-a)using namespace std;str...
阅读全文

浙公网安备 33010602011771号