![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
模板
youniverser
这个作者很懒,什么都没留下…
展开
-
有源汇有上下界最小流 模板
#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 51000;const int M = 402000;const ll inf = 0x3f3f3f3f;template <class Ruby>inline void read(Ruby &x...原创 2019-10-09 11:16:26 · 85 阅读 · 0 评论 -
有源汇有上下界最大流 模板
//有源汇有上下界最大流#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=2005,maxm=100005;const int inf=0x7f7f7f7f;struct edge{ int to,next,w,num...原创 2019-10-09 11:15:52 · 116 阅读 · 0 评论 -
有(无)源汇 有上下界可行流 模板
//无源汇有上下界可行流(循环流)/*模型:一个网络,求出一个流,使得每条边的流量必须>=Li且<=Hi,每个点必须满足总流入量=总流出量(流量守恒)(这个流的特点是循环往复,无始无终)可行流算法的核心是将一个不满足流量守恒的初始流调整成满足流量守恒的流.流量守恒,即每个点的总流入量=总流出量如果存在一个可行流,那么一定满足每条边的流量都大于等于流量的下限.因此我们可以令每条...原创 2019-10-09 11:15:18 · 96 阅读 · 0 评论 -
费用流 SPFA
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#define ll long long#define inf 50000000#define re regis...原创 2019-10-09 11:14:10 · 92 阅读 · 0 评论 -
费用流 dijkstra
#pragma GCC optimize(2)#include <iostream>#include <algorithm>#include <queue>#include <math.h>#include <stdio.h>#include <string.h>#include <algorithm>...原创 2019-10-09 11:12:58 · 120 阅读 · 0 评论 -
dinic 模板
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int inf = 0x3f3f3f3f;const int maxn = 1e5+10;int n,m,cnt;int st,ed;int head[maxn], cur[maxn], dis[maxn];struct node{...原创 2019-10-09 11:12:23 · 80 阅读 · 0 评论 -
splay树模板
//splay树#include <bits/stdc++.h>using namespace std;const int maxn = 2e5+10;struct splay_tree{ int fa,cnt,ch[2],val,size;}t[maxn];int root,tot;void update(int x){t[x].size = t[t[x].c...原创 2019-10-09 08:04:25 · 89 阅读 · 0 评论 -
划分树 模板
// 划分树 nlogn建树 logn查询区间第k小#include <bits/stdc++.h>using namespace std;const int maxn = 1e5+10;int tree[20][maxn];//表示每层每个位置的值int sorted[maxn];//放排好序的数int toleft[20][maxn];//void build(int...原创 2019-10-09 08:03:34 · 91 阅读 · 0 评论 -
ST表模板
//O(nlogn)预处理 O(1)查询#include <bits/stdc++.h>using namespace std;const int maxn = 1e6+10;int st[maxn][21];int query(int l,int r){//区间最值查询 int k = log2(r-l+1); return max(st[l][k],st[...原创 2019-10-06 11:48:40 · 91 阅读 · 0 评论 -
主席树模板
#include<bits/stdc++.h>using namespace std;const int N=1e5+10;vector<int>v;struct node{ int l,r,s;}t[N*40];int rt[N],a[N],cnt;int get(int x){return lower_bound(v.begin(),v.end(...原创 2019-10-06 11:48:18 · 76 阅读 · 0 评论 -
Trie树模板
#include <bits/stdc++.h>using namespace std;//对于字符串比较多的要统计个数的,map被卡的情况下,直接用字典树//很多题都是要用到节点下标来表示某个字符串const int maxn =2e6+5;//如果是64MB可以开到2e6+5,尽量开大int tree[maxn][30];int fg[maxn];//标记是否为单词结束...原创 2019-10-06 11:47:37 · 70 阅读 · 0 评论 -
大数模板C++
#include <bits/stdc++.h>using namespace std;struct BigInteger{ static const int BASE = 100000000; //和WIDTH保持一致 static const int WIDTH = 8; //八位一存储,如修改记得修改输出中的%08d bool sign...原创 2019-10-06 11:47:06 · 63 阅读 · 0 评论 -
树状数组相关 模板
树状数组区间和单点修改查询的模板#include <bits/stdc++.h>using namespace std;const int maxn = 1e6+10;int a[maxn],n,x,y,k,sum;inline int lowbit(int x) {return x&-x;}//单点修改 区间查询void update(int x,int k){...原创 2019-09-18 10:40:47 · 89 阅读 · 0 评论 -
Miller Rabin 素数测试 模板
ll mul(ll a, ll b, ll mod){ a %= mod; b %= mod; ll res = 0; while (b){ if (b&1){ res += a; if (res >= mod) res -= mod; } b >&g...原创 2019-08-03 20:10:31 · 77 阅读 · 0 评论 -
快速乘法模板
使用二进制将乘法转换为加法,既可以加快速度也能防止乘法溢出ll mul(ll a, ll b, ll mod){ a %= mod; b %= mod; ll res = 0; while (b){ if (b&1){ res += a; if (res >= mod) res -= m...原创 2019-07-31 09:42:02 · 66 阅读 · 0 评论 -
欧拉函数的求解 模板
1.欧拉函数:小于n中与n互质的数的数目 φ(1) = 1是积性函数φ(mn) = φ(m)φ(n)n为质数时φ(n) = n-1单个数的欧拉函数计算void get_phi(int n) { int res = n; for (int i = 2; i * i <= n; ++i) { if (n % i == 0) { r...原创 2019-07-31 09:10:44 · 125 阅读 · 0 评论