随笔分类 -  数据结构

摘要:哈希表 O(log2n) 点击查看代码 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int,int> mp; for (int i = 0; i < num 阅读全文
posted @ 2023-02-12 19:54 wKingYu 阅读(12) 评论(0) 推荐(0) 编辑
摘要:带扩展域的并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N]; struct Node { int a, b; 阅读全文
posted @ 2022-08-16 21:18 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:并查集 + 树的判定 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; int p[N]; int find(int x) { if (p[ 阅读全文
posted @ 2022-08-16 17:22 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:带扩展域的并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N]; int find(int x) { if (p 阅读全文
posted @ 2022-08-16 16:47 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:并查集 + 树的判定 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e4 + 10; int n; int p[N]; int find(int x) { if (p[ 阅读全文
posted @ 2022-08-16 14:21 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:贪心 + 小根堆 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; const int N = 1e6 + 10; int n; void solv 阅读全文
posted @ 2022-08-15 23:41 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:带权并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N], d[N]; int find(int x) { if 阅读全文
posted @ 2022-08-12 23:32 wKingYu 阅读(37) 评论(0) 推荐(0) 编辑
摘要:带权并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N], d[N]; int find(int x) { if 阅读全文
posted @ 2022-08-12 22:39 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:先合并集合,最后统计集合个数 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N]; int find(int x) { 阅读全文
posted @ 2022-08-11 23:55 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:先合并集合,最后统计多少学生和 0 号学生属于同一集合 并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int a[N] 阅读全文
posted @ 2022-08-11 23:49 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:特定条件合并集合 并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, d; int p[N]; bool open[N]; struc 阅读全文
posted @ 2022-08-11 23:34 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:单点修改(更新),区间查询(最大值) 线段树 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n, m; int w[N]; struct No 阅读全文
posted @ 2022-08-11 23:07 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:单点修改(增加),区间查询(区间和) 线段树 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n; int w[N]; struct Node 阅读全文
posted @ 2022-08-11 22:56 wKingYu 阅读(19) 评论(0) 推荐(0) 编辑
摘要:线段树 区间修改(加,乘),区间查询(求和) 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n, m, p; LL w[N]; struct 阅读全文
posted @ 2022-07-30 10:46 wKingYu 阅读(20) 评论(0) 推荐(0) 编辑
摘要:线段树 区间修改,区间查询(和) 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n, m; int w[N]; struct Node { i 阅读全文
posted @ 2022-07-21 17:25 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:线段树,转换为差分数组 单点修改,区间查询(和,最大公约数) 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n, m; LL w[N]; st 阅读全文
posted @ 2022-07-21 11:34 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:线段树 单点修改,区间查询(子段和的最大值) 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n, m; int w[N]; struct No 阅读全文
posted @ 2022-07-20 23:40 wKingYu 阅读(9) 评论(0) 推荐(0) 编辑
摘要:线段树 单点修改,区间查询(最大值) 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int m, p; struct Node { int l, r; 阅读全文
posted @ 2022-07-20 20:49 wKingYu 阅读(20) 评论(0) 推荐(0) 编辑
摘要:树状数组 + 二分 复杂度 nlog2(n) 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n; int h[N]; 阅读全文
posted @ 2022-07-19 23:33 wKingYu 阅读(19) 评论(0) 推荐(0) 编辑
摘要:树状数组 区间修改,区间查询 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n, m; LL a[N]; LL tr1[N], tr2[N]; 阅读全文
posted @ 2022-07-19 22:16 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑

欢迎阅读『数据结构』
点击右上角即可分享
微信分享提示