并查集
最爱晴天和自己
等待
展开
-
poj1611 The Suspects(并查集)
n个学生分属m个团体,(0 < n <= 30000 , 0 <= m <= 500) 一个学生可以属于多个团体。一个学生疑似患病,则它所属的整个团体都疑似患病。已知0号学生疑似患病,以及每个团体都由哪些学生构成,求一共多少个学生疑似患病。 Input The input file contains several cases. Each test case beg...原创 2018-08-20 15:07:12 · 169 阅读 · 0 评论 -
POJ 1988 Cube stacking
有N(N<=30,000)堆方块,开始每堆都是一个方块。方块编号1 – N. 有两种操作: M x y : 表示把方块x所在的堆,拿起来叠放到y所在的堆上。 C x : 问方块x下面有多少个方块。 操作最多有 P (P<=100,000)次。对每次C操作,输出结果。 Input * Line 1: A single integer, P * Lines 2..P+1: Eac...原创 2018-08-22 08:58:13 · 146 阅读 · 0 评论 -
HDU 6187 Destroy Walls(并查集+最大生成树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6187 Problem Description Long times ago, there are beautiful historic walls in the city. These walls divide the city into many parts of area. ...原创 2018-10-25 18:24:53 · 233 阅读 · 0 评论