
模板
文章平均质量分 77
做不完的ACM
加油,努力
展开
-
Splay模板
#include using namespace std;const int N = 1E5 + 7, MOD = 1000000;int size[N], cnt[N], key[N], ch[N][2], f[N];int res, sz, rt;void clear(int x) {cnt[x]=size[x]=key[x]=ch[x][0]=ch[x][1]=f原创 2018-01-12 11:28:46 · 156 阅读 · 0 评论 -
权值线段树模板
#include <bits/stdc++.h>using namespace std;#define lson l,mid,rt<<1#define rson mid+1,r,rt<<1|1const int maxn = 1e5 + 7;int A[maxn<<2], son[maxn];int n, q, par[maxn];...原创 2018-05-21 21:01:09 · 425 阅读 · 1 评论 -
网络流P3381 最小费用最大流模板
#include <bits/stdc++.h>using namespace std;const int maxn = 5050, INF = 0x7f7f7f7f;struct Edge{ int from, to, cap, flow, cost; Edge():from(0),to(0),cap(0),flow(0),cost(0){} Ed...原创 2018-05-07 17:23:18 · 155 阅读 · 0 评论 -
2018年湘潭大学程序设计竞赛 H线段树染色
链接:https://www.nowcoder.com/acm/contest/105/H来源:牛客网题目描述n个桶按顺序排列,我们用1~n给桶标号。有两种操作: 1 l r c 区间[l,r]中的每个桶中都放入一个颜色为c的球 (1≤l,r ≤n,l≤r,0≤c≤60) 2 l r 查询区间[l,r]的桶中有多少种不同颜色的球 (1≤l,r ≤n,l≤r)输入描述:有多组数据,对于每...原创 2018-04-26 23:15:34 · 188 阅读 · 0 评论 -
BM递推杜教版
#include <bits/stdc++.h>using namespace std;#define rep(i,a,n) for (long long i=a;i<n;i++)#define per(i,a,n) for (long long i=n-1;i>=a;i--)#define pb push_back#define mp make_pair#d...原创 2018-05-11 00:12:40 · 2651 阅读 · 2 评论 -
网络流 Dinic模板
#include <bits/stdc++.h>using namespace std;const int maxn = 1024, INF = 0x3f3f3f3f;struct Edge{ int from, to, cap, flow; Edge() { from = to = cap = flow = 0; } Edg...原创 2018-04-25 20:35:29 · 170 阅读 · 0 评论 -
Tarjan算法求割点和桥
#include<iostream>using namespace std;#include<cstdio>#include<cstring>#include<vector>#define N 201vector<int>G[N];int n,m,low[N],dfn[N];bool is_cut[N];in...原创 2018-03-20 12:58:17 · 296 阅读 · 0 评论 -
Codeforces 938E组合数学逆元
题目链接:http://codeforces.com/contest/938/problem/E题意:给你n个数字,求所有排列的fa的和:对于一个排列来说,一开始fa为1,m=1,若a[m]<a[i] fa=fa+a[m]。题解:我们考虑一个数的贡献,若这个数能产生贡献,则比这个数大的数都在这个数后面(包括相等),那么我们就可以得到如下能得到贡献的数目。意思为:从n个位置中挑出n-i+1(大...原创 2018-03-12 22:32:02 · 230 阅读 · 0 评论 -
BITSET里的用法
引用:http://blog.youkuaiyun.com/tri_integral/article/details/11098033用法:1.初始化:bitset<标记数组大小> 数组名称(初始值,二进制的比如0xffff)默认所有位都是0any():有一位为1就返回1none():所有位都为0返回1count():返回1的个数set(n):第n位置1set():全部置1reset(n):第n位...原创 2018-03-08 00:39:53 · 202 阅读 · 0 评论 -
4种基础lis变形
#include <bits/stdc++.h>using namespace std;const int N = 1E5 + 7, INF = 0x3f3f3f3f;int a[N], dp[N];int n;int p1() //严格上升{ int len = 1; memset(dp, 0x3f, sizeof(dp)); dp[1]...原创 2018-02-07 20:52:19 · 292 阅读 · 0 评论 -
Tarjan模板
#include <bits/stdc++.h>using namespace std;#define SZ(X) ((int)X.size())#define mp make_pair#define pb push_back#define RALL(X) X.rbegin(),X.rend()#define ALL(X) X.begin(),X.end()using...原创 2018-02-12 01:30:00 · 149 阅读 · 0 评论 -
数组求交集并集
#include <bits/stdc++.h>using namespace std;#define SZ(X) ((int)X.size())#define mp make_pair#define pb push_back#define RALL(X) X.rbegin(),X.rend()#define ALL(X) X.begin(),X.end()using ll = lon...原创 2018-02-11 22:47:52 · 348 阅读 · 0 评论 -
平面最近点对模板
#include #include #include #include #include using namespace std;typedef long long int ll;struct P{ ll x, y; bool operator }p[100050];ll dis(P &A, P &B) { return (A.x-B.x原创 2018-01-26 23:42:35 · 324 阅读 · 0 评论 -
HihoCoder1684
题目链接:http://hihocoder.com/problemset/problem/1684#include using namespace std;using ll = long long ;using ld = long double ;#define ALL(X) begin(X), end(X)#define mp make_pair#define原创 2018-01-15 00:46:25 · 186 阅读 · 0 评论 -
湖北省赛持久化字典树
题解:主席树维护,利用前缀和思想做差贪心。题目链接:https://www.nowcoder.com/acm/contest/104#question#include <bits/stdc++.h>using namespace std;const int maxn = 1e5 + 7;struct node{ int nxt[2], v;}t[maxn * ...原创 2018-05-27 02:08:14 · 149 阅读 · 0 评论