最大流模版 pascal】的更多相关文章

//最大流模版 ; maxm=; ..maxn] of integer; end; var n,m,max:longint; r:..maxn,..maxn] of longint; g:..maxn,..maxn] of integer; d,cur:Array[..maxn] of integer; h:..maxn] of integer;//h表示高度 L:..maxn*-] of list; e:..maxn] of longint;//e表示盈余 Buf:Array[..] of c…
题意: n行, a房间的气球,b房间的气球 i行需要的气球,与a房的距离,b房的距离 求最小距离 #include <stdio.h> #include <string.h> #include <iostream> #include <math.h> #include <queue> #include <set> #include <algorithm> #include <stdlib.h> #define…
好久都没有搞博客了.想认真写又要准备文化课期末了. ISAP 流程: 原理就是dfs找增广路. 最基础的建反向边以便反悔就不说了. 但是记录一个dep(dis)表示层数,一开始BFS(从t开始,dis[t]=0)处理最小层数,然后再搜索增广路增加限制条件:dis[u]=dis[v]+1,若这样的v找完了,扩大一层u(即dis[u]++),可能会被回溯到前面的某条新路再次搜中.然后特判一下,如果dis[s]>=n即可结束,因为dis[t]永远等于0,dis[s]最大为n-1. gap(cnt)标记…
#include <iostream> #include<cstdio> #include<queue> #include<cstring> using namespace std; #define INF 0xfffffff #define N 210 int cap[N][N],flow[N][N]; int pre[N],dist[N]; int ek(int sta,int end){ int i,curr,sum=0; memset(flow,0,…
/************************************************************** Problem: 3876 User: wangck1998 Language: C++ Result: Accepted Time:176 ms Memory:1456 kb ****************************************************************/ #include <bits/stdc++.h> using…
朴素dinic+多路增广 #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #include <queue> using namespace std; const int MAXM=100005,MAXN=10005; int init(){ int rv=0,fh=1; char c=get…
EK算法基于增广路的思想,易于理解,但由于低效并不被经常使用 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <queue> using namespace std; const int MAXN=10005,MAXM=100005; int n,m,s,flow,t,nume…
题意:现在有m个池塘(从1到m开始编号,1为源点,m为汇点),及n条有向水渠,给出这n条水渠所连接的点和所能流过的最大流量,求从源点到汇点能流过的最大流量 Dinic #include<iostream> #include<cstring> #include<algorithm> #include <cstdio> #include <queue> using namespace std; ; const int INF = 0x3f3f3f3f…
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <queue> using namespace std; const int MAXN = 5005; int init() { int rv = 0, fh = 1; char…
费用流模版: #include<cstdio> #include<cstring> #include<queue> using namespace std; ;//最大边数 ;//最大点数 struct Edge{ Edge(){}; Edge(int a,int b,int c,int d,int e){ u=a; v=b; f=c; w=d; nxt=e; } int u,v,f,w,nxt;//U当前点 V来自点 F最大流量 W费用 NXT下一个点 }; ;//边…