
并查集
永夜莫明
菜是原罪
展开
-
Is It A Tree?
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 prope...原创 2018-11-15 19:47:46 · 277 阅读 · 0 评论 -
All men are brothers(并查集+动态规划/组合数学)
链接:https://ac.nowcoder.com/acm/contest/889/E来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述Amy asks Mr. B problem E. Please help Mr. B to solve the followin...原创 2019-08-15 21:40:15 · 375 阅读 · 0 评论 -
Truthman or Fakeman(推理,种类并查集/dfs)
链接: https://ac.nowcoder.com/acm/contest/893/G来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536KSpecial Judge, 64bit IO Format: %lld题目描述有n个人在玩一个身份扮演的游戏。把这n个人编号为1,2,3...n。其中每个人会扮演下面两种身份中的一种...原创 2019-05-09 10:30:32 · 673 阅读 · 0 评论 -
D-City
Luxer is a really bad guy. He destroys everything he met.One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D-line connects exactly two D-points. Luxer will destroy all the D-li...原创 2018-12-31 15:11:42 · 321 阅读 · 0 评论 -
7-14 拯救007 (25 分)(暴力)(并查集)
7-14 拯救007 (25 分)在老电影“007之生死关头”(Live and Let Die)中有一个情节,007被毒贩抓到一个鳄鱼池中心的小岛上,他用了一种极为大胆的方法逃脱 —— 直接踩着池子里一系列鳄鱼的大脑袋跳上岸去!(据说当年替身演员被最后一条鳄鱼咬住了脚,幸好穿的是特别加厚的靴子才逃过一劫。)设鳄鱼池是长宽为100米的方形,中心坐标为 (0, 0),且东北角坐标为 (50, 5...原创 2018-12-17 09:34:11 · 1708 阅读 · 0 评论 -
7-32 文件传输 (25 分) (并查集水题)
7-32 文件传输 (25 分)当两台计算机双向连通的时候,文件是可以在两台机器间传输的。给定一套计算机网络,请你判断任意两台指定的计算机之间能否传输文件?输入格式:首先在第一行给出网络中计算机的总数 N (2≤N≤104 ),于是我们假设这些计算机从 1 到 N 编号。随后每行输入按以下格式给出:I c1 c2其中I表示在计算机c1和c2之间加入连线,使它们连通;或者是C ...原创 2018-12-07 15:47:15 · 1348 阅读 · 0 评论 -
7-31 朋友圈 (25 分)
7-31 朋友圈 (25 分)某学校有N个学生,形成M个俱乐部。每个俱乐部里的学生有着一定相似的兴趣爱好,形成一个朋友圈。一个学生可以同时属于若干个不同的俱乐部。根据“我的朋友的朋友也是我的朋友”这个推论可以得出,如果A和B是朋友,且B和C是朋友,则A和C也是朋友。请编写程序计算最大朋友圈中有多少人。输入格式:输入的第一行包含两个正整数N(≤30000)和M(≤1000),分别代表学校的学生...原创 2018-12-07 15:31:58 · 300 阅读 · 0 评论 -
Segment set
Segment setA segment and all segments which are connected with it compose a segment set. The size of a segment set is the number of segments in it. The problem is to find the size of some segment set...原创 2018-11-17 10:58:14 · 870 阅读 · 0 评论 -
小希的迷宫 (并查集)
小希的迷宫 (并查集)上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计...原创 2018-11-14 21:30:50 · 202 阅读 · 0 评论 -
so easy(unordered_map+并查集)
https://nanti.jisuanke.com/t/41384There are nnn points in an array with index from 111 to nnn, and there are two operations to those points.1: 1x1 \ x1x marking the point xxx is not available2...原创 2019-09-07 23:31:24 · 294 阅读 · 0 评论