随笔 - 530  文章 - 0  评论 - 3  阅读 - 10098 

随笔分类 -  并查集

CF1850H
摘要:带权并查集板题 维护到根的距离 #include <iostream> #include <algorithm> #include <cstring> #include <vector> #include <queue> using namespace std; const int N =2e5+1 阅读全文
posted @ 2023-10-05 21:29 towboat 阅读(5) 评论(0) 推荐(0) 编辑
并查集的操作(update
摘要:maintain block size: fa[fy]=fx; sz[fx]+=sz[fy],sz[fy]=0; 阅读全文
posted @ 2023-10-03 15:26 towboat 阅读(1) 评论(0) 推荐(0) 编辑
uva 1329
摘要:并查集路径压缩中,维护某节点到根节点的距离(依题意为abs(x-y)%1000) 即 d[i] +=d[father[i] ] #include <iostream> #include <algorithm> #include <cmath> using namespace std; const i 阅读全文
posted @ 2022-10-14 13:34 towboat 阅读(11) 评论(0) 推荐(0) 编辑
uva 1160
摘要:并查集判断图上是否有环 #include <iostream> #include <algorithm> using namespace std; const int N=1e5+4; int fa[N]; int find(int x){ return x==fa[x]?x:fa[x]=find( 阅读全文
posted @ 2022-10-14 13:05 towboat 阅读(5) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示