有木有非常吊 加强 加强版   啊  ,看了都不敢做了   .后来先做了食物链这个我还是看过的.但还是A不掉,没明确神魔意思 .总而言之.大牛的博客是个好东西.我就那么看了一下,还是不懂怎莫办啊,哎,就那样就A掉了. ... . .. 今天我们来谈一下这个并查集的删除操作,依据我对大牛的理解啊,这个并查集的删除操作并非把原来的节点删除掉,而是用一个替身替掉,如今的这个点仅仅是用作桥梁的作用,即是没用的,del  ,,,del  ,...删除,那些被删掉的就从n開始给他们一个地址,然后即例如以下代…
传送门 题意: 每次合并两份邮件,或者将某一份邮件独立出来,问最后有多少个邮件集合. 分析: 考虑初始化每个节点的祖先为一个虚父节点(i + n),虚父节点指向它自己.这样可以进行正常的合并操作. 而在删除时,将该节点的祖先置为一个更大的数(++anc_cnt),并让该anc_cnt指向它自己,这样不会影响与自身节点相连的所有关系.最后统计有多少个不同的祖先即可. code #include<bits/stdc++.h> using namespace std; const int N = 1…
思路:每次合并时,都是给一个虚拟的根. #include<map> #include<Set> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #include<cstdlib> #include<cstring> #include<iostream> #include&…
虚拟数组 待定/.#include<iostream> #include<algorithm> #include<set> using namespace std; int f],n,m; int hash1]; set<int> st; void init() { for;i<n;i++) { f[i]=i; hash1[i]=i; } } int find(int x) { if(x==f[x]) return f[x]; f[x]=find(f[…
湫湫系列故事——设计风景线 Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 4539    Accepted Submission(s): 816 Problem Description 随着杭州西湖的知名度的进一步提升,园林规划专家湫湫希望设计出一条新的经典观光线路,根据老板马小腾的指示,新的风景线最好能建成环形,如果没有条件建成环形,…
给出两个图,问你是不是同构的... 直接通过并查集建图,暴力用SET判断下子节点个数就行了. /** @Date : 2017-09-22 16:13:42 * @FileName: HDU 3926 并查集 图同构 连通分量.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/st…
给你n个点m条边,保证已经是个连通图,问每次按顺序去掉给定的一条边,当前的连通块数量. 与其正过来思考当前这边会不会是桥,不如倒过来在n个点即n个连通块下建图,检查其连通性,就能知道个数了 /** @Date : 2017-09-21 23:26:20 * @FileName: HDU 4496 并查集 逆向思维.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github…
http://acm.hdu.edu.cn/showproblem.php?pid=2473 http://acm.fzu.edu.cn/problem.php?pid=2155 题目大意: 编号0~n-1的电子邮件,让你进行归类. M X Y表示x y是同一类的,而S X则取消之前X的分类.问你经过M次这样的操作后,有多少类相同的邮件. 思路: 下午FZU月赛有这题.不过我没参加- -||||,先暂时退出ACM一段时间.事情多.得先去搞定那个外包的软件了 并查集的应用.多开了一个数组real,…
Junk-Mail Filter Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8640    Accepted Submission(s): 2735 Problem Description Recognizing junk mails is a tough task. The method used here consists…
Description Recognizing junk mails is a tough task. The method used here consists of two steps:  1) Extract the common characteristics from the incoming email.  2) Use a filter matching the set of common characteristics extracted to determine whether…