随笔分类 - 平衡树
摘要:#include <bits/stdc++.h> using namespace std; const int N = 3e5+10; const int INF = 0x3fffffff; int first = 1; int n, m, a, b, c; int rt; char op[10];
阅读全文
摘要:关于Splay的几个灵魂问题 写着一篇文章的目的在于,我被几道带有lazy标记的题折磨了很久。 1. Splay是在维护节点值的顺序吗? 我们先来看一看常规的splay定义: const int N = 1e5+5; struct Node{ int s[2]; // 左右儿子 int p; //
阅读全文
摘要:Splay+离散化 - HDU 3436 - Queue-jumpers 因为太菜怕离散化写错,一开始尝试着写在线算法竟然还过了(玄学复杂度不会证明,貌似破坏了splay的期望logN)。本文先介绍离线的正解,文末附在线算法的代码。 1. 离线算法 离散化其实挺好想,数据范围N=1e8肯定不可能开一
阅读全文
摘要:Splay - POJ 3481 - Double Queue Splay模板题,实现插入、删除、前驱后继函数。加入左右哨兵可以更加方便地查询最值。 #include <bits/stdc++.h> using namespace std; const int N = 1e6+5; const in
阅读全文
摘要:并查集 + splay启发式合并 - AcWing 1063 - 永无乡 本题用并查集维护连通性,用splay支持在线查询第k大。为了使得splay能够完成合并操作,本题需要利用启发式的思想,即每次合并都将节点数少的splay的所有节点加入到节点数较多的splay中去。可以证明,splay的启发式合
阅读全文
摘要:Splay - AcWing 950 - 郁闷的出纳员 之前做过这道题目,当时是用权值线段树做的。本题还可以用splay做,splay用于维护一些区间问题。这是第一道凭个人记忆打出的splay模板,可以说对于splay有一个基本的理解了。 #include <bits/stdc++.h> using
阅读全文
摘要:伸展树-Splay 对于本题的区间flip操作,线段树难以实现;用splay来做非常合适。 #include <bits/stdc++.h> using namespace std; const int N = 1e5+50; int n,m; struct Node{ int s[2],p,v;
阅读全文
摘要:[模板] fhq Treap (无旋Treap) 模板题AcWing253.普通平衡树 教程视频 #include <cstdio> #include <algorithm> #include <queue> using namespace std; const int N = 1e5+5; str
阅读全文