ICode9

精准搜索请尝试: 精确搜索
  • P3369 【模板】普通平衡树 avl树数组版2022-04-10 21:31:07

    P3369 【模板】普通平衡树 //avl数组版 #include<bits/stdc++.h> using namespace std; const int maxn=100010; struct avlnode{ int val; int size; int cnt; int height; int ls; int rs; }avl[maxn]; int root,tot; int height(int rt) { return avl[rt].height; } v

  • P3369 【模板】普通平衡树 替罪羊树解法2022-03-20 08:03:09

    P3369 【模板】普通平衡树 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #define lc ch[p][0] #define rc ch[p][1] using namespace std; const int N=100010; const int inf=0x3f3f3f3f; const double alpha=0.75; int n,m;

  • P3369 【模板】普通平衡树 splay解法2022-03-20 08:02:36

    P3369 【模板】普通平衡树 #include <bits/stdc++.h> using namespace std; const int N = 200005; int ch[N][2], par[N], val[N], cnt[N], size[N], ncnt, root; bool chk(int x) { return ch[par[x]][1] == x; } void pushup(int x) { size[x] = size[ch[x][0]] + si

  • P3369 【模板】普通平衡树 例题 各种算法的比较2021-11-10 15:01:25

    P3369 【模板】普通平衡树 当你在考场上碰到这样的平衡树题,你会写哪个? 排行榜(个人观点): 离散化+树状数组 小常数 \(O(n\log^2 n)\): FHQ Treap 较大常数 \(O(n\log n)\): __gnu_pbds 红黑树严格 \(O(n\log n)\): Treap 普通的 \(O(n\log n)\): Splay 大常数的 \(O(n\log n)\):

  • 【luogu P3369】普通平衡树(Treap 做法)2021-05-24 10:31:43

    普通平衡树 题目链接:luogu P3369 题目大意 平衡树模板题,要求维护一些操作。 插入一个数,删除一个数,查询一个数的排名,查询排名一直的数,找前驱后继。 思路 写 fhq Treap 之前突然发现自己剪贴板里面有个半年前写完的 Treap 没写题解,又发现没有一道 Treap 的题解,然后就过来补题解

  • 题解 洛谷 P3369 【模板】普通平衡树2021-05-23 15:03:00

    普通平衡树模板题,这里我写的是 Treap 。 Treap 大概是最最最基本的平衡树了吧(基本上就是 BST 上加了个堆性质) 关于 Treap 的坑点: 哪里都不能丢的 update :只要你的操作涉及父子关系的修改,就不要忘记更新子树大小。 代码简化:用 \(son[i][0/1]\) 存储左右儿子而非 \(ls[i]\) 和 \(rs

  • P3369 【模板】普通平衡树(Treap/SBT)2021-05-20 22:58:25

    题目描述 您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作: 插入x数 删除x数(若有多个相同的数,因只删除一个) 查询x数的排名(排名定义为比当前数小的数的个数+1。若有多个相同的数,因输出最小的排名) 查询排名为x的数 求x的前驱(前驱定义为小于x,且最

  • 【动态开点线段树】洛谷P3369 【模板】普通平衡树2021-04-11 19:04:53

    本题使用动态开点权值线段树... 数据返回是 [-1e7,1e7] ,所以将其 +(1e7+1) 让范围映射到 [1,2e7+1] ,这样就在 [1,2e7+1] 构建权值线段树,记 2e7+1 为 MAXN; 先考虑前面 4 种操作 插入和删除操作就是在线段树的叶子节点(递归的最底层)的位置 +-1,表示该点的个数,向上 push_up 维护区间 [

  • 洛谷P3369 普通平衡树2020-02-27 22:58:33

      题目描述 您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作: 插入 xx 数 删除 xx 数(若有多个相同的数,因只删除一个) 查询 xx 数的排名(排名定义为比当前数小的数的个数 +1+1 ) 查询排名为 xx 的数 求 xx 的前驱(前驱定义为小于 xx,且最大的

  • 洛谷 P3369 【模板】普通平衡树2020-01-29 16:53:53

    写平衡树真的是要自闭……一个多小时终于写完+调完了(或许我是一区\(62\)级信息组里最晚会\(treap\)的人了……) 发现写\(treap\)的题解比较少……于是自己看着黄学长的代码写了一篇,注释写的很明白,都在代码里了,不过要注意的是在做这道题之前一定要先学会二叉搜索树和堆,否则就会很难

  • P3369 【模板】普通平衡树 (splay)2019-07-28 23:52:30

    splay支持查询 1.第k大 2.第k大是谁 3.数的前驱 4.数的后继 5.添加删除   #include <bits/stdc++.h>using namespace std;int rt, cnt;int ch[100005][2]; //左右儿子int fa[100005]; //父节点int sz[100005]; //字树和int cn[100005]; //当前点出现了多少

  • Luogu P3369 【模板】普通平衡树2019-06-01 11:04:13

    解法 就是最普通的splay啦,直接放代码QAQ 代码 #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<cmath> #define INF 0x3f3f3f3f using namespace std; typedef long long LL; const int N=1e5+5; int read() { int

  • fhq_treap || P3369 【模板】普通平衡树2019-05-24 19:53:21

    题面:【模板】普通平衡树 代码: 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<cstdlib> 5 using namespace std; 6 inline int rd(){ 7 int x=0,f=1;char c=getchar(); 8 while(c<'0'||c>'9'){if

  • 洛谷P3369 普通平衡树2019-03-28 14:42:32

    平衡树板子 因为之前写spaly删除出了大锅。。所以就去学了一手fhq-treap。。。 下面是抄来的板子(真香 #include <bits/stdc++.h> #define INF 0x3f3f3f3f #define full(a, b) memset(a, b, sizeof a) using namespace std; typedef long long ll; inline int lowbit(int x){ retur

  • 洛谷P3369 【模板】普通平衡树 01trie/骚操作2019-02-13 15:45:20

    Code: #include <cstdio> #include <algorithm> #include <cstring> #define setIO(s) freopen(s".in","r",stdin) #define maxn 100010 * 33 using namespace std; int root=1,tot=1,sumv[maxn],n,opt,x,ch[maxn][2]; void ins(int

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有