[POJ1611]The Suspects(并查集)


传送门

通过并查集统计集合个数,easy

——代码

1 #include <cstdio> 2 #include <iostream> 3 #define N 1000001 4 5 int n, m; 6 int f[N], num[N]; 7 8 inline int read() 9 16 17 inline int find(int x) 18 21 22 inline void connect(int x, int y) 23 28 29 int main() 30 46 } 47 printf("%d\n", num[find(0)]); 48 } 49 return 0; 50 }
View Code



上一篇:[TyvjP1515] 子串统计 [luoguP2408] 不同子串个数(后缀数组)

下一篇:[CODEVS1916] 负载平衡问题(最小费用最大流)


并查集
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图