随笔分类 - 数据结构-并查集
摘要:动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说
阅读全文
摘要:Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that
阅读全文
摘要:"链接6081" 度度熊的王国战略 Time Limit: 40000/20000 MS (Java/Others) Memory Limit: 32768/132768 K (Java/Others) Total Submission(s): 923 Accepted Submission(s):
阅读全文
摘要:"CF" A. Party time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output A company has n employees numb
阅读全文
摘要:题意:对trees有四种操作。 1 u v ,将包含u th树的森林和含有v th树的森林 合并 在一起; u ,将u th树与森林分开; 3 u ,查询包含u th树的森林的大小; 4 u v ,查询u th树和v th树是否在同一林中。 【分析】:给每个点都给他们造一个编号w,删除点,就相当于该
阅读全文
摘要:``` 链接:https://www.nowcoder.com/acm/contest/84/C 来源:牛客网 题目描述 平面上有若干个点,从每个点出发,你可以往东南西北任意方向走,直到碰到另一个点,然后才可以改变方向。 请问至少需要加多少个点,使得点对之间互相可以到达。 输入描述: 第一行一个整数
阅读全文
摘要:https://www.patest.cn/contests/gplt/L2-024 首先在一行中输出这个社区的总人数、以及互不相交的部落的个数。随后对每一次查询,如果他们属于同一个部落,则在一行中输出“Y”,否则输出“N”。 /* 求连通分量,先记录下原始的连通分量,每删除一个点,删去相应的边(这
阅读全文
摘要:L2-010. 排座位 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 时间限制 150 ms 时间限制 150 ms 内存限制 65536 kB 内存限制 65536 kB 代码长度限制 8000 B 代码长度限制 8000
阅读全文
摘要:Description 如果无向图G每对顶点v和w都有从v到w的路径,那么称无向图G是连通的。现在给定一张无向图,判断它是否是连通的。 Input 第一行有2个整数n和m(0 < n,m < 1000000), 接下来m行每行有2个整数u,v (1<=u,v<=n)表示u和v有边连接。 Output
阅读全文
摘要:C. Rumor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output C. Rumor time limit per test 2
阅读全文
摘要:Junk-Mail Filter Time Limit: 15000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8640 Accepted Submission(s): 2
阅读全文
摘要:Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that
阅读全文
摘要:An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unex
阅读全文
摘要:Description 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 cont
阅读全文
摘要:The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. H
阅读全文