
并查集
m悟空
这个作者很懒,什么都没留下…
展开
-
Mr. Kitayuta's Colorful Graph(二维并查集)
Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color ci, connecting vertex a...原创 2018-08-19 21:37:46 · 284 阅读 · 0 评论 -
Welcome Party (并查集 + 优先队列)
The 44th World Finals of the International Collegiate Programming Contest (ICPC 2020) will be held in Moscow, Russia. To celebrate this annual event for the best competitive programmers around the wor...原创 2019-04-28 17:28:25 · 731 阅读 · 0 评论 -
Almost Union-Find (带权值的并查集 + 分离节点 )
I hope you know the beautiful Union-Find structure. In this problem, you’re to implement something similar, but not identical. The data structure you need to write is also a collection of disjoint se...原创 2019-04-22 16:29:07 · 334 阅读 · 0 评论 -
How Many Answers Are Wrong (带权值的并查集)
TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should ...原创 2019-03-21 16:40:21 · 128 阅读 · 0 评论 -
带劲的and和 (并查集找联通 + 二进制运算)
度度熊专门研究过“动态传递闭包问题”,他有一万种让大家爆蛋的方法;但此刻,他只想出一道简简单单的题——至繁,归于至简。 度度熊有一张n个点m条边的**无向图**,第ii个点的点权为vivi。 如果图上存在一条**路径**使得点ii可以走到点jj,则称i,ji,j是**带劲**的,记f(i,j)=1f(i,j)=1;否则f(i,j)=0f(i,j)=0。显然有f(i,j)=f(j,i)f(i,j...原创 2019-03-20 21:12:59 · 278 阅读 · 0 评论 -
产生冠军 (并查集)
有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛。 球赛的规则如下: 如果A打败了B,B又打败了C,而A与C之间没有进行过比赛,那么就认定,A一定能打败C。 如果A打败了B,B又打败了C,而且,C又打败了A,那么A、B、C三者都不可能成为冠军。 根据这个规则,无需循环较量,或许就能确定冠军。你的任务就是面对一群比赛选手,在经过了若干场撕杀之后,确定是否已经实际上产生了冠军。...原创 2018-07-19 09:37:41 · 410 阅读 · 0 评论 -
小希的迷宫 (并查集)
上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给你,让你帮忙判断她的...原创 2018-08-09 17:03:17 · 383 阅读 · 0 评论 -
Is It A Tree? (并查集)
A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties. There ...原创 2018-08-09 17:13:13 · 1994 阅读 · 0 评论 -
食物链 (并查集 好题)
动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物,用上述两种说法,一句接一句地说出K句话,...原创 2018-08-09 17:33:08 · 2280 阅读 · 0 评论 -
Parity(带权值的并查集)
你的朋友写下一串包含1和0的串让你猜,你可以从中选择一个连续的子串(例如其中的第3到第5个数字)问他,该子串中包含了奇数个还是偶数个1,他会回答你的问题,然后你可以继续提问......你怀疑朋友的答案可能有错,或说同他之前的答案相互矛盾,例如:1 - 2 奇数,3 - 4 奇数,那么可以确定1 - 4 一定是偶数,如果你的朋友回答是奇数,就产生了矛盾。给出所有你朋友的答案,请你找出第一个出现矛盾的...原创 2018-08-16 17:30:41 · 853 阅读 · 0 评论 -
Ice_cream's world I (并查集求环的个数)
ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wall between watchtower...原创 2018-08-16 16:05:44 · 344 阅读 · 0 评论 -
家庭作业(贪心 + 并查集)
老师在开学第一天就把所有作业都布置了,每个作业如果在规定的时间内交上来的话才有学分。每个作业的截止日期和学分可能是不同的。例如如果一个作业学分为,要求在天内交,那么要想拿到这学分,就必须在第天结束前交。 每个作业的完成时间都是只有一天。例如,假设有 7 次作业的学分和完成时间如下: 最多可以获得学分,其中一个完成作业的次序为,注意可能还有其他方法。 你的任务就是找到一个...原创 2019-05-15 21:28:29 · 2479 阅读 · 0 评论