![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
文章平均质量分 60
phantom_kiddo
队友是自己最好的榜样,也是最强的对手。
展开
-
HDU1213(并查集)
并查集水题 #include #include #include #include #include #include using namespace std; const int maxn = 1111; int fa[maxn]; int n, m; void init() { for(int i=0; i<=n; i++) { fa[i] = i原创 2016-02-03 15:24:17 · 199 阅读 · 0 评论 -
HDU3635(并查集)
题目大意:n个龙珠,q个操作。操作T是将第Ath所在的城市里的所有龙珠移向第Bth龙珠所在的城市;操作Q是询问第Ath龙珠所在的城市、所在城市的龙珠总数,以及第Ath龙珠被移动的次数。 #include #include #include #include #include #include using namespace std; const int maxn = 11111; s原创 2016-02-03 15:29:30 · 393 阅读 · 0 评论 -
HDU4496(并查集)
题目大意:给一个N个顶点,M条边的无向完全图,每次删边之后输出剩余连通块的数量。 思路:并查集 一般是用并查集加边的,这题可以想象成删掉1条边,相当于增加M-1条边,然后离线操作,将答案储存起来一并输出。 #include #include #include #include #include #include using namespace std; const int max原创 2016-02-04 14:48:06 · 244 阅读 · 0 评论 -
HDU5631(并查集)
题目大意:n个顶点,n+1条边,问删除几个边之后仍是连通图的方案数有多少? 思路:如果图连通的话,只能删1~2条边,而且题目数据小,所以暴力就好。 #include #include #include #include #include #include using namespace std; int fa[111]; int from[111], to[111]; int n;原创 2016-02-24 14:17:47 · 584 阅读 · 0 评论