• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Codjjj
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

随笔分类 -  数据结构

 
启发式合并板子(梦幻布丁)
摘要:Link 启发式合并是针对n个集合(总元素个数是O(n))的合并操作,每次将小的集合合并到大的集合 复杂度证明: 考虑每一个元素$$e \in E$$的贡献,如果在某一次合并中该元素被移动,那么集合的大小至少是$$2|E|$$,故复杂度是$$O(nlogn)$$ 具体的题目而言,我们可以看出对于$$ 阅读全文
posted @ 2023-03-25 16:26 _Codjjj 阅读(47) 评论(0) 推荐(0)
欧拉序+ST表 O(nlogn+q)求LCA
摘要:欧拉序:每次遍历到树上的一个点,就加进欧拉序 如 1 2 3 ​ 4 5 这颗树的欧拉序是121343431 这样我们可以发现一个重要的性质:两个点的LCA是欧拉序之间dep最小的点 易发现这是对的,因为LCA肯定会在欧拉序之间,而LCA的祖先不会,因为如果会,说明LCA的这颗子树已经被遍历完了,那 阅读全文
posted @ 2023-03-20 20:48 _Codjjj 阅读(201) 评论(0) 推荐(0)
[模板]主席树
摘要:第K小数 #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int N = 100010; struct Node{ int l,r; in 阅读全文
posted @ 2021-10-25 17:45 _Codjjj 阅读(34) 评论(0) 推荐(0)
[模板]可持久化Trie
摘要:可持久化Trie模板 最大亦或和 题解 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int M=6e5+10; int n,m; int h[25*M][2]; int 阅读全文
posted @ 2021-10-16 18:07 _Codjjj 阅读(40) 评论(0) 推荐(0)
[转载]算法学习笔记(75): Gosper's Hack
摘要:https://zhuanlan.zhihu.com/p/360512296 能快速算出n的集合的k元子集 阅读全文
posted @ 2021-09-08 08:55 _Codjjj 阅读(150) 评论(0) 推荐(0)
经典题:map写bfs
摘要:#include<bits/stdc++.h> #define x first #define y second using namespace std; int order[8] = { 4,1,2,3,6,7,8,5 }; int order2[8] = { 1,7,2,4,5,3,6,8 }; 阅读全文
posted @ 2021-09-01 11:32 _Codjjj 阅读(44) 评论(0) 推荐(0)
莫队+离散化
摘要:#include<bits/stdc++.h> #define ll long long using namespace std; const int N=3e5,M=5e5; int n,m,k,maxn; int a[N],b[N],c[N]; ll num[N]; ll curn; int p 阅读全文
posted @ 2021-09-01 11:30 _Codjjj 阅读(33) 评论(0) 推荐(0)
模板:树状数组
摘要:#include<bits/stdc++.h> using namespace std; const int N=500; int a[N]; int ask(int x){ int ans=0; for(;x;x-=x&-x)ans+=a[x],x-=x&-x; return ans; } voi 阅读全文
posted @ 2021-09-01 11:27 _Codjjj 阅读(29) 评论(0) 推荐(0)
ST树的创建
摘要:#include<bits/stdc++.h> using namespace std; const int N = 10010; const int M = 13; int n; int a[N]; int f[N][M]; void ST_create() { for (int i = 1; i 阅读全文
posted @ 2021-06-08 19:51 _Codjjj 阅读(89) 评论(0) 推荐(0)
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3