随笔分类 - 数据结构
摘要:树状数组 区间修改,单点查询 点击查看代码 #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
阅读全文
摘要:树状数组 复杂度 单点修改, 区间查询 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n; int a[N]
阅读全文
摘要:点击查看代码 #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] !=
阅读全文
摘要:带边权的并查集 点击查看代码 #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,
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:并查集 + 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
阅读全文
摘要:点击查看代码 #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)
阅读全文
摘要:点击查看代码 #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];
阅读全文
摘要:拉链法 点击查看代码 #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 = (
阅读全文
摘要:点击查看代码 #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]
阅读全文
摘要:点击查看代码 #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])
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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;
阅读全文
摘要:点击查看代码 #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;
阅读全文
摘要:点击查看代码 #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;
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #include<iostream> #include<stack> #include<cstring> #include<unordered_map> using namespace std; stack<int> nums; stack<char> op; unordered_ma
阅读全文
摘要:点击查看代码 #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 --
阅读全文