![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
文章平均质量分 88
小鸡炖蘑菇_
stay hungry,stay foolish.
展开
-
hdu 1875 畅通工程再续
Problem Description相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于1000米。当然原创 2015-08-24 16:11:31 · 355 阅读 · 0 评论 -
并查集详解 (转)
来看一个实例,杭电1232畅通工程 首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通,或者问你整幅图一共有几个连通分支,也就是被分成了几个互相独立的块。像畅通工程这题,问还需要修几条路,实质就是求有几个连通分支。如果是1个连通分支,说明整幅图上的点都连起来了,不用再修路了;如果是转载 2015-08-14 19:49:59 · 412 阅读 · 0 评论 -
hdu-1558-Segment set(计算几何&并查集)
Problem DescriptionA 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 segme原创 2016-01-23 16:03:45 · 506 阅读 · 0 评论 -
hdu-1198-Farm Irrigation(并查集)
Problem DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square has a原创 2016-01-23 10:53:27 · 346 阅读 · 0 评论 -
hdu-1598-find the most comfortable road( 并查集&贪心)
Problem DescriptionXX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Structure—超级空中漫游结构)进行交流,每条SARS都对行驶在上面的Flycar限制了固定的Speed,同时XX星人对 Flycar的“舒适度”有特殊要求,即乘坐过程中最高速度与最低速度的差越小乘坐越舒服 ,(理解为SARS的限速要求,flycar必须瞬间提速/降速,原创 2016-01-23 09:37:41 · 275 阅读 · 0 评论 -
hdu-3038-How Many Answers Are Wrong(并查集)
Problem DescriptionTT and FF are … friends. Uh… very very good friends -__-bFF 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 s原创 2016-01-22 23:11:40 · 263 阅读 · 0 评论 -
HNACM(六) 第三题 最舒适的路线
题目描述异形卵潜伏在某区域的一个神经网络中。其网络共有N个神经元(编号为1,2,3,…,N),这些神经元由M条通道连接着。两个神经元之间可能有多条通道。异形卵可以在这些通道上来回游动,但在神经网络中任一条通道的游动速度必须是一定的。当然异形卵不希望从一条通道游动到另一条通道速度变化太大,否则它会很不舒服。现在异形卵聚居在神经元S点,想游动到神经元T点。它希望选择一条游动过程中通道最大速度与最小速度原创 2015-11-25 19:41:57 · 461 阅读 · 0 评论 -
HDU 1213 How Many Tables
HDU 1213 How Many TablesProblem Description 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原创 2015-08-15 20:42:45 · 283 阅读 · 0 评论 -
UVa10596 Morning Walk
UVa10596 Morning WalkKamal is a Motashota guy. He has got a new job in Chittagong. So, he has moved to Chittagong from Dinajpur. He was getting fatter in Dinajpur as he had no work in his hand there. S原创 2015-08-14 20:13:09 · 407 阅读 · 0 评论 -
HDU1856 More is better
HDU1856 More is betterProblem Description Mr 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 cert原创 2015-08-14 19:59:02 · 366 阅读 · 0 评论 -
POJ 2524 Ubiquitous Religions
POJ 2524 Ubiquitous ReligionsDescription 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 r原创 2015-08-14 20:51:17 · 289 阅读 · 0 评论 -
BNU 4216.修路
在某个景区内有n个景点,它们之间有m条路相连。然而,这m条路可能是不足够的,因为无法把这n个景点都连通起来。 例如当m<n-1的时候,就必定有部分景点被孤立。 所以,现在政府想修建道路,想把这些景点都连通起来。问题是,在现在的基础上,最少要再修建多少条道路呢? Input 第一行是n,m (1<=n<=1e5,1<=m<=1e6)接下来就是m行,每行两个1 ~ n范围内的数,表示编号为这两原创 2015-08-14 20:42:28 · 511 阅读 · 0 评论 -
HDU1272 小希的迷宫
HDU1272 小希的迷宫Problem Description 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以原创 2015-08-14 19:32:07 · 340 阅读 · 0 评论 -
UVa 10397 - Connect the Campus
Many new buildings are under construction on the campus of the University of Waterloo. The university has hired bricklayers, electricians, plumbers, and a computer programmer. A computer programmer? Ye原创 2015-08-24 16:47:38 · 801 阅读 · 0 评论 -
hdu 1233 还是畅通工程
http://acm.hdu.edu.cn/showproblem.php?pid=1233Problem Description某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试用例原创 2015-08-24 16:19:03 · 321 阅读 · 0 评论 -
畅通工程
省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。Input测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M ( < 100 );随后的 N 行对应村庄间道路的成本,每行给出一对正整原创 2015-08-24 16:00:26 · 606 阅读 · 0 评论 -
POJ 1611 The Suspects
POJ 1611 The SuspectsDescription 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原创 2015-08-14 21:00:29 · 369 阅读 · 0 评论