数据结构
micaudience
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
CF lesson 并查集
求最右 支持两种操作: 删除节点操作 询问某一节点右侧没有被删除的第一个节点。 //直线 const int N = 1e6 + 10; int f[N]; int findf(int x) { if(f[x] == x) return x; f[x] = findf(f[x]); return f[x]; } int main() { int n, m; scanf("%d%d", &n, &m); for(int i = 1; i <= n; i++) f[i] =原创 2020-09-18 09:23:10 · 171 阅读 · 0 评论 -
笛卡尔树
一、定义 将一个序列构造成满足如下条件的一棵树: 父节点比子节点小(大) 树的中序遍历,与原序列相同 [6, 2, 8, 1, 7, 3, 5]这个序列可以建成如下图所示的笛卡尔树。 二、构造 将根、根的右子树、根的右子树的右子树……加入栈内 插入新元素时,将栈内比当前元素大的元素弹出,然后将当前元素作为栈顶元素的右子树,栈中最后一个被弹出的元素为该元素的左子树。将该元素插入栈内。 注意当前元素没有左子树或当前元素为根的情况。 void build() { rt = 1; stk[1] =原创 2020-07-21 17:34:25 · 198 阅读 · 0 评论 -
树套树
ZJOI2013 K大数 权值线段树+区间线段树 //需要开启O2优化 #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<cmath> using namespace std; const int N=5e4+10; struct TREE{ long long sum,f; int原创 2020-05-15 22:54:09 · 226 阅读 · 0 评论 -
虚树
题目 消耗战 虚树+DP 注意,如果一个节点为资源岛,就一定要被切断,无需讨论它的子节点是不是资源岛。 #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<cmath> us...原创 2020-04-30 22:56:41 · 173 阅读 · 0 评论 -
主席树与带修主席树
模板 #include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<cstring> using namespace std; const int N=2e5+10; struct TREE{...原创 2020-04-20 19:21:53 · 263 阅读 · 0 评论
分享