luogu
kkjy_00
这个作者很懒,什么都没留下…
展开
-
P1168 中位数
动态维护中位数 用一个大根堆和一个小根堆,大根堆存前一半,小根堆存后一半,大根堆堆顶就是中位数 #include<cstdio> #include<queue> using namespace std; const int maxn = 1e5 + 5; int ans[maxn]; priority_queue<int,vector<int>,gre...原创 2019-02-08 15:11:52 · 183 阅读 · 0 评论 -
P3391 【模板】文艺平衡树(Splay)
#include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int inf = 1e9; int root, tot; int key[maxn], cnt[maxn], siz[maxn], tag[maxn], fa[maxn]; int ch[maxn][2], a[maxn]; vo...原创 2019-07-26 14:48:11 · 89 阅读 · 0 评论 -
P3224 [HNOI2012]永无乡
线段树合并 #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int a[maxn], id[maxn], prt[maxn], root[maxn]; char s[5]; int tot; struct node{ int l, r, sum; } tree[maxn*20]; inli...原创 2019-07-26 14:35:51 · 79 阅读 · 0 评论 -
P2801 教主的魔法
分块大法 #include<bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; char s[5]; int a[maxn], b[maxn]; int L[maxn], R[maxn], belong[maxn], lazy[maxn]; int block, num; inline int read() {...原创 2019-07-21 21:53:13 · 103 阅读 · 0 评论 -
P3302 [SDOI2013]森林
主席树+启发式合并 更新lca倍增表时,原本是dfs(x,0),所以更新父亲时放在for循环里不会出现问题,但是在进行合并操作后,更新倍增表就会出现问题 #include<bits/stdc++.h> using namespace std; const int maxn = 8e4 + 5; int a[maxn], prt[maxn], T[maxn], sum[maxn];...原创 2019-07-30 10:19:16 · 110 阅读 · 0 评论 -
P1330 封锁阳光大学
二分图染色 #include<bits/stdc++.h> using namespace std; const int maxn = 1e4 + 5; const int maxm = 1e5 + 5; int ver[maxm*2], Next[maxm*2], head[maxn]; int col[maxn]; int tot, flag, white, black, an...原创 2019-05-29 22:21:32 · 65 阅读 · 0 评论 -
P2161 [SHOI2009]会场预约
线段树染色题 #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; char s[5]; int ans, tmp, col; int del[maxn*2]; struct node{ int l, r, tag, v; } tree[maxn*4]; void build(int k,int...原创 2019-06-07 13:37:10 · 81 阅读 · 0 评论 -
P2661 信息传递
图中最小环算法 不断删除图中入度为0的点,最终图中只剩下环,依次跑一遍,求出最小的环 #include<bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int a[maxn], in[maxn], vis[maxn]; int ans = 0x7fffffff; inline int read() { ...原创 2019-05-28 21:52:42 · 111 阅读 · 0 评论 -
P1303 A*B Problem
高精度乘法模板 #include<iostream> #include<cstdio> #include<string> #include<cstring> using namespace std; int main() { string s1, s2; int a[2005], b[2005], c[4010]; cin...原创 2019-02-27 13:54:28 · 80 阅读 · 0 评论 -
P2142 高精度减法
高精度减法模板 #include<iostream> #include<cstdio> #include<string> #include<cstring> using namespace std; int cmp(string s1,string s2) { if(s1.length() > s2.length()) return...原创 2019-02-27 13:30:57 · 131 阅读 · 0 评论 -
P1601 A+B Problem(高精)
高精度加法模板 #include<iostream> #include<cstdio> #include<string> #include<cstring> using namespace std; int main() { int a[505], b[505], len; memset(a,0,sizeof(a)); m...原创 2019-02-27 13:08:48 · 500 阅读 · 0 评论 -
P3371 【模板】单源最短路径(弱化版)
#include<cstdio> #include<cstring> #include<queue> #include<utility> using namespace std; const int maxn_v = 1e4 + 5; const int maxn = 5e5 + 5; int ver[maxn], edge[maxn], next...原创 2019-02-27 10:14:37 · 186 阅读 · 0 评论 -
P1255 数楼梯
高精度 楼梯有N阶,上楼可以一步上一阶,也可以一步上二阶。 编一个程序,计算共有多少种不同的走法。 f[i][j] i表示第i阶,第二维高精度 #include<cstdio> using namespace std; int f[5005][5005], len; int main() { int n; scanf("%d",&n); if(n ==...原创 2019-02-28 11:02:56 · 189 阅读 · 0 评论 -
P1020 导弹拦截
nlogn求最长上升子序列 #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn = 1e5 + 5; int n, a[maxn], f[50005], maxx; int lowbit(int x){return x&(...原创 2019-02-27 21:51:21 · 79 阅读 · 0 评论 -
P4146 序列终结者
splay模板题 #include<bits/stdc++.h> using namespace std; const int maxn = 5e4 + 5; const int inf = 1e9; int a[maxn], key[maxn], siz[maxn], fa[maxn], cnt[maxn]; int tag[maxn], add[maxn], mx[maxn],...原创 2019-07-26 14:48:58 · 128 阅读 · 0 评论