【模板】权值线段树
摘要:#define lc(x) (x<<1) #define rc(x) (x<<1|1) struct tree { int num; int l, r; }node[maxn]; inline void build(int x, int l, int r) { node[x].num = 0; no
阅读全文
posted @
2019-12-04 14:34
thjkhdf12
阅读(178)
推荐(0)
【模板】dijstra最小费用最大流
摘要:int cnt; int h[maxn]; int prep[maxn]; int pree[maxm]; int dis[maxn]; int st = maxn - 2; int ed = maxn - 1; struct Edge { int v, nxt; int w, f; }e[maxm
阅读全文
posted @
2019-11-27 14:53
thjkhdf12
阅读(124)
推荐(0)
【模板】dinic算法网络最大流
摘要:int d[maxn]; int now[maxn]; int st,ed; void add_dinic(int u, int v) { e[++cnt].v = v; e[cnt].w = 0; e[cnt].nxt = head[u]; head[u] = cnt; } int dfs_din
阅读全文
posted @
2019-11-08 22:46
thjkhdf12
阅读(149)
推荐(0)
【模板】spfa
摘要:int dis_spfa[maxn]; bool vis_spfa[maxn]; queue<int>q_spfa; void spfa(int x) { mem(dis_spfa, 0x3f); mem(vis_spfa, false); dis_spfa[x] = 0; q_spfa.push(
阅读全文
posted @
2019-10-30 17:29
thjkhdf12
阅读(99)
推荐(0)
【模板】tarjan求割点
摘要:int dfn[maxn]; int low[maxn]; bool cut[maxn]; int tot; void tarjan(int x) { dfn[x] = low[x] = ++tot; int cntf = 0; for (Re int i = head[x]; i != -1; i
阅读全文
posted @
2019-10-23 10:41
thjkhdf12
阅读(72)
推荐(0)
【模板】dijstra
摘要:typedef struct { bool operator ()(const intpair& a, const intpair& b)const { return a.second > b.second; } }cmp_dij; int dis_dij[maxn]; bool vis_dij[m
阅读全文
posted @
2019-10-22 13:19
thjkhdf12
阅读(148)
推荐(0)
【模板】tarjan
摘要:int dfn[maxn]; //第i个点被dfs到次序 int low[maxn]; //二叉搜索树上i所在子数上仍在栈中的最小dfn,low[i]相等的点在一个强连通分量中 bool vis_tarjan[maxn]; stack<int>s_tarjan; int tot_tarjan; in
阅读全文
posted @
2019-10-20 16:57
thjkhdf12
阅读(155)
推荐(0)
【模板】快速乘/快速幂
摘要:inline long long fpro(long long x,long long y,long long p) { long long z=(long double)x/p*y; long long res=(unsigned long long)x*y-(unsigned long long)z*p; return (res+p)%p; } inline ...
阅读全文
posted @
2019-10-11 20:36
thjkhdf12
阅读(127)
推荐(0)
【模板】树状数组
摘要:int n; const int maxn = 100010; int a[maxn]; int sum1[maxn]; int sum2[maxn]; inline int lowbit(int x) { return x & (-x); } inline void updata(int i, int k) { int x = i; while (i <= n) { sum1[i] += k;
阅读全文
posted @
2019-10-11 13:30
thjkhdf12
阅读(130)
推荐(0)
【模板】线段树(min,add)
摘要:const int maxn = 5000010; int a[maxn]; #define lc(x) x<<1 #define rc(x) x<<1|1 il int min(int a, int b) { return a > b ? b : a; } struct tree { int a;
阅读全文
posted @
2019-10-11 13:06
thjkhdf12
阅读(161)
推荐(0)
【模板】链式前向星
摘要:int cnt; struct Edge { int v, nxt; //int w; }e[maxn]; int head[maxn]; inline void init() { memset(head, -1, sizeof(head)); } void add(int u, int v/*,i
阅读全文
posted @
2019-10-09 17:40
thjkhdf12
阅读(109)
推荐(0)
【模板】头文件
摘要:#include<iostream> #include<string> #include<queue> #include<stack> #include<vector> #include<map> #include<cstdio> #include<cstdlib> #include<algorit
阅读全文
posted @
2019-10-09 17:35
thjkhdf12
阅读(167)
推荐(0)
【模板】并查集
摘要:1 const int maxn = 100010; 2 int fa[maxn]; 3 4 int find(int x) 5 { 6 if (fa[x] == x) return x; 7 fa[x] = find(fa[x]); 8 return fa[x]; 9 } 10 11 void merge(int a, int b) 12 { 13...
阅读全文
posted @
2019-10-09 13:59
thjkhdf12
阅读(95)
推荐(0)