最大流dinic模板】的更多相关文章

标准的大白书式模板,除了变量名并不一样……在主函数中只需要用到 init 函数.add 函数以及 mf 函数 #include<stdio.h> //差不多要加这么些头文件 #include<string.h> #include<queue> #include<vector> #include<algorithm> using namespace std; +; //点的总数 const int INF=0x3f3f3f3f; struct ed…
循环版,点的编号从0开始: ; ; const int INF = 0x3f3f3f3f; struct Edge { int to, next, cap, flow; }edge[MAXM]; int tol; int head[MAXN]; void init() { tol = ; memset(head, -, sizeof(head)); } ) { edge[tol].to = v; edge[tol].cap = w; edge[tol].flow = ; edge[tol].ne…
#include <bits/stdc++.h> using namespace std; #define MP make_pair #define PB push_back #define ls first #define rs second typedef long long LL; typedef pair<int,int> PII; ; const double pi=acos(-1.0); ; ; vector<pair<int,int>>mp[K…
拆点,套模板. 详情见代码. // // main.cpp // hdu_4289 // // Created by Luke on 16/8/29. // Copyright © 2016年 Luke. All rights reserved. // //hdu-4289 #include <iostream> #include <vector> #include <queue> #define N 500 //开两倍大小多一些 #define INF 0x3f3f3…
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n, m, S, T; ;//点数的最大值 ;//边数的最大值 const int INF = 0x3f3f3f3f; struct Edge { int to,next,cap,flow; } edge[MAXM]; //注意是MAXM int tol; int head[MAXN]; void init()…
//非当前弧优化版 #include <iostream> #include <cstdio> #include <math.h> #include <cstring> #include <queue> #define INF 0x3f3f3f3f using namespace std; int tab[250][250];//邻接矩阵 int dis[250];//距源点距离,分层图 int N,M;//N:点数;M,边数 queue<…
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<cmath> #include<vector> using namespace std; ; const int INF=0x7fffffff; int n,m;//n:edges,m:points struct node…
#include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; queue<int>q; int INF=1e9; ],cur[],ct=,s,t,d[],ans; struct N{ int to,next,w; }edge[]; void add(int x,int y,int z) { edge[++ct]=(N){y,he…
ISAP // UVa11248 Frequency Hopping:使用ISAP算法,加优化 // Rujia Liu struct Edge { int from, to, cap, flow; }; struct ISAP { int n, m, s, t; vector<Edge> edges; vector<int> G[maxn]; // 邻接表,G[i][j]表示结点i的第j条边在e数组中的序号 bool vis[maxn]; // BFS使用 int d[maxn]…
之前的Dinic模板照着刘汝佳写的vector然后十分鬼畜跑得奇慢无比,虽然别人这样写也没慢多少但是自己的就是令人捉急. 改成邻接表之后快了三倍,虽然还是比较慢但是自己比较满意了.虽然一开始ecnt从0开始WA了一发... 之前的码风也十分鬼畜呀缩进只缩1.2格不懂自己怎么想的.. 反正今天就安心划划水. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #in…