摘要: 先合并集合,最后统计集合个数 点击查看代码 #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 阅读(20) 评论(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 阅读(21) 评论(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 阅读(15) 评论(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 阅读(13) 评论(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 阅读(17) 评论(0) 推荐(0) 编辑