摘要:
异或的性质 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; int a[N]; void solve() { cin >> n; for 阅读全文
摘要:
带权并查集 点击查看代码 #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 阅读全文
摘要:
带权并查集 点击查看代码 #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 阅读全文
摘要:
先合并集合,最后统计集合个数 点击查看代码 #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) { 阅读全文
摘要:
先合并集合,最后统计多少学生和 $0$ 号学生属于同一集合 并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int a[N] 阅读全文
摘要:
特定条件合并集合 并查集 点击查看代码 #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 阅读全文
摘要:
单点修改(更新),区间查询(最大值) 线段树 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n, m; int w[N]; struct No 阅读全文
摘要:
单点修改(增加),区间查询(区间和) 线段树 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n; int w[N]; struct Node 阅读全文
摘要:
二分 + 双端队列广搜 复杂度 $m \cdot log(r - l) = 1 \times 10^4 \times log(10^9) = 3 \times 10^5$ 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long 阅读全文
摘要:
最短路 + DFS 枚举顺序 最短路用堆优化 dijkstra 复杂度 $O(m \cdot log(n)) = 10^5 \cdot log(5 \times 10^4) \approx 1.56 \times 10^6$ DFS 枚举复杂度 $O(n!) = 5! = 120$ 两个复杂度是相加 阅读全文