摘要: 题目链接:http://acm.fzu.edu.cn/problem.php?pid=2155思路:在一般的并查集操作中设立虚父亲节点,当删除x的时候,不是真的删除x,而是通过一个映射,即令tmp[x] = cnt, parent[cnt] = cnt;这样x就从原来的集合中独立出来了,而我们每次合并x,y的时候,只需合并tmp[x], tmp[y]就可以了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int MAXN = (2000000 +100... 阅读全文
posted @ 2014-03-26 17:44 ihge2k 阅读(342) 评论(2) 推荐(0) 编辑