![](https://img-blog.csdnimg.cn/2019092715111047.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
并查集
图论
Aloof__
笔记是记忆的缓冲
展开
-
ICPC North Western European Regional Contest 2019
整理的算法模板:ACM算法模板总结(分类详细版)Table of ContentsF. Firetrucks Are RedE. Expeditious CubingF. Firetrucks Are Red如何用并查集建立联系呢?首先对于第i行中的每个数,如果之前这个数存在过,位置为 x ,那么就把 i 和 x 所在的连通块合并(注意:如果本身就在一个联通里则不需要加任何边,避免存储不必要的边);并且更新这个数的位置为i;最后判断所有的点是否在一个连通块即...原创 2020-05-09 21:51:11 · 389 阅读 · 0 评论 -
poj 2492 A Bug's Life 二分图 并查集
BackgroundProfessor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gende...原创 2019-09-28 15:46:35 · 149 阅读 · 0 评论 -
Zjnu Stadium HDU - 3047(加权并查集)
In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of people. The audience Seats made a circl...原创 2019-09-06 10:23:43 · 156 阅读 · 0 评论 -
How Many Tables HDU - 1213(并查集)
Today is Ignatius’ birthday. He invites a lot of friends. Now it’s dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, a...原创 2019-09-06 07:57:36 · 163 阅读 · 0 评论 -
Dragon Balls HDU - 3635(类似加权并查集)
Five hundred years later, the number of dragon balls will increase unexpectedly, so it’s too difficult for Monkey King(WuKong) to gather all of the dragon balls together.His country has N cities and...原创 2019-09-05 23:23:35 · 127 阅读 · 0 评论 -
Cube Stacking POJ - 1988(带权并查集)
Farmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start with N stacks, each containing a single cube. Farmer John asks Betsy to perform ...原创 2019-09-05 08:53:40 · 115 阅读 · 0 评论 -
Ubiquitous Religions POJ - 2524(并查集)
There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university beli...原创 2019-09-04 08:34:32 · 83 阅读 · 0 评论 -
The Suspects POJ - 1611(并查集)
Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to s...原创 2019-09-03 21:46:33 · 85 阅读 · 0 评论 -
Tom的战力问题
单点时限: 2.0 sec内存限制: 512 MBTom被斯派克揍了TAT。Tom下定决心要战胜斯派克。但是在战胜最强的斯派克之前,Tom要先打败其他的狗。为此,他打算先收集一下信息。现在Tom在了得到了一些关于战斗力的小道消息,例如X号狗狗的战力比Y号狗狗的战力高S点。Tom想知道利用这些消息,能不能判断出某两只狗之间的战力高低?高多少?输入格式第一行包含三个整数N,M和Q。N...原创 2019-08-25 18:18:57 · 173 阅读 · 0 评论 -
并查集模板(包括带权并查集)
find函数int find(int x) //查找我(x)的掌门{ int r=x; //委托 r 去找掌门 while (pre[r ]!=r) //如果r的上级不是r自己(也就是说找到的大侠他不是掌门) r=pre[r ] ; //...原创 2019-08-09 19:14:36 · 305 阅读 · 0 评论