随笔分类 -  数据结构

摘要:树状数组 区间修改,单点查询 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n, m; LL a[N]; LL tr[N]; int lowb 阅读全文
posted @ 2022-07-19 21:31 wKingYu 阅读(19) 评论(0) 推荐(0) 编辑
摘要:树状数组 复杂度 nlog(n) 单点修改, 区间查询 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n; int a[N] 阅读全文
posted @ 2022-07-19 20:53 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 3e4 + 10; int p[N], sz[N], d[N]; int find(int x) { if (p[x] != 阅读全文
posted @ 2022-07-19 16:16 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:带边权的并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e5 + 10; int n, m; int p[N], d[N]; unordered_map<int, 阅读全文
posted @ 2022-07-18 19:06 wKingYu 阅读(44) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n, m; int p[N]; unordered_map<int,int> s; struct 阅读全文
posted @ 2022-07-16 11:37 wKingYu 阅读(28) 评论(0) 推荐(0) 编辑
摘要:并查集 + 01背包 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e5 + 10; int n, m, k; int p[N]; int v[N], w[N]; in 阅读全文
posted @ 2022-07-16 11:05 wKingYu 阅读(30) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e5 + 10; int n, m; int p[N]; int find(int x) { if (p[x] != x) 阅读全文
posted @ 2022-07-16 10:52 wKingYu 阅读(27) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; typedef unsigned long long ULL; const int N = 1e5 + 10; const int P = 131; int h[N], p[N]; char str[N]; 阅读全文
posted @ 2022-05-03 22:16 wKingYu 阅读(39) 评论(0) 推荐(0) 编辑
摘要:拉链法 点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 1e5 + 3; int h[N], e[N], ne[N], idx; void insert(int x) { int k = ( 阅读全文
posted @ 2022-05-03 19:35 wKingYu 阅读(31) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int h[N], sz, m; int ph[N], hp[N]; void heap_swap(int a, int b) { swap(ph[hp[a] 阅读全文
posted @ 2022-05-03 17:44 wKingYu 阅读(34) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int h[N], sz; void down(int u) { int t = u; if (2 * u <= sz && h[2 * u] < h[t]) 阅读全文
posted @ 2022-05-03 15:50 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int p[N], sz[N]; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x 阅读全文
posted @ 2022-05-02 21:28 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int p[N]; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x]; } in 阅读全文
posted @ 2022-05-02 20:54 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; const int M = 5e6 + 10; int son[M][2], idx; int a[N]; void insert(int x) { int 阅读全文
posted @ 2022-05-02 20:04 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 6e5 + 10; int son[N][26], cnt[N], idx; char str[N]; void insert(char str[]) { int p = 0; 阅读全文
posted @ 2022-05-02 17:15 wKingYu 阅读(28) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e6 + 10; int a[N], q[N]; int main() { int n, k; scanf("%d %d", &n, &k); for (int i = 0; 阅读全文
posted @ 2022-04-30 17:02 wKingYu 阅读(32) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int stk[N], tt = 0; int main() { int n; scanf("%d", &n); while (n --) { int x; 阅读全文
posted @ 2022-04-30 16:14 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int q[N]; int l = 0, r = 0; void push(int x) { q[r] = x; r ++; } void pop() { l 阅读全文
posted @ 2022-04-30 00:37 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<stack> #include<cstring> #include<unordered_map> using namespace std; stack<int> nums; stack<char> op; unordered_ma 阅读全文
posted @ 2022-04-30 00:29 wKingYu 阅读(36) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int s[N], idx = 0; void push(int x) { s[idx] = x; idx ++; } void pop() { idx -- 阅读全文
posted @ 2022-04-29 23:26 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑

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