
并查集
心夏心冬
心夏心冬
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
并查集总结
用自己的理解来写好了 有些地方可能不对 不定时更新理解操作主要为三步 一 初始化void init(){ for (int i = 0; i < n; ++i) { par[i] = i; rank[i] = 0; //用于防退化 }}二 查找这个为路径压缩 就是每次查找时更新 查找节点(x) 上面所有节点直接使他们连向根节原创 2017-03-09 13:55:16 · 340 阅读 · 0 评论 -
HDU5326 work
DescriptionIt’s an interesting experience to move from ICPC to work, end my college life and start a brand new journey in company. As is known to all, every stuff in a company has a title, everyone e原创 2017-08-03 10:23:41 · 262 阅读 · 0 评论 -
并查集 判环
Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给原创 2017-08-03 09:23:14 · 1793 阅读 · 0 评论 -
HDU1856More is better
DescriptionMr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it will be. Of course there are certain requirements. Mr Wang select原创 2017-08-03 09:17:47 · 324 阅读 · 0 评论 -
HDU1213How Many Tables
DescriptionToday 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 eac原创 2017-08-03 09:13:53 · 222 阅读 · 0 评论 -
poj1611The Suspects
DescriptionSevere 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 strate原创 2017-08-03 09:10:27 · 231 阅读 · 0 评论 -
HDU5631 Rikka with Graph
DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has a non-direct graph with n vertices and原创 2017-08-03 09:06:29 · 302 阅读 · 1 评论 -
畅通工程
Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路,每原创 2017-08-03 08:44:49 · 211 阅读 · 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原创 2017-03-04 11:15:26 · 311 阅读 · 0 评论 -
偶数树 并查集
Description给你一棵有n个节点的树(一个无环简单图),节点序号为1~n,根节点为1。 请你找出一个最大的整数k,表示从这棵树上断掉k条边使其所有的子树的节点数都为偶数。Input第一行输入两个整数N,M。表示这棵树有N个节点和M条边。 接下来有M行,每行输入两个整数u,v,表示u节点和v节点间有一条边相连。数据保证:2 ≤ n ≤ 100,并且所有的节点都在一棵树上。 输入的树总能被原创 2017-06-07 21:43:54 · 670 阅读 · 0 评论 -
Vegetable and Road [并查集]
公园终于建好了,市政府要求任意两个公园之间必须连通,即公园A到公园B至少有一条马路(并不是要求直接相连,可以通过其他公园间接相连)。Vegetable接下来这个任务,并设计出了对应的修路方案,下面你需要判断Vegetable的方案是否可行。注意:两个公园直接可以存在多条路。输入 有T组测试数据,每组测试数据有一组N(0#include<cstdio>#include<cstring>#incl原创 2017-03-06 22:37:03 · 293 阅读 · 0 评论 -
Rank of Tetris HDU - 1811 拓扑排序 并查集
Description自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。 为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新,名堂要比福布斯富豪榜还响。关于如何排名,这个不用说都知道是根据Rating从高到低来排,如果两个人具有相同的Rating,那就按这几个人的RP从高到低来排。 终于,Lel原创 2017-08-06 20:59:12 · 274 阅读 · 0 评论