![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
文章平均质量分 85
尉水风
这个作者很懒,什么都没留下…
展开
-
Restructuring Company
Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, discard and merge departments, fire employees and do other unpleasant stuff. Let原创 2017-07-20 17:13:14 · 666 阅读 · 0 评论 -
Assign the task
数据据说很水,用并查集写的There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate bo原创 2017-08-09 21:33:03 · 433 阅读 · 0 评论 -
Mr. Kitayuta's Colorful Graph
数据量很小用搜索或并查集应该都能过题目要求:从一个点到另一个点可以经过多少条不同的边思路:为每一条不同编号的边建一个并查集,查看有多少条边可以使这两个点有共同的父节点 B. Mr. Kitayuta's Colorful GraphMr. Kitayuta has just b原创 2017-08-11 21:30:10 · 287 阅读 · 0 评论 -
Arpa's weak amphitheater and Mehrdad's valuable Hoses
背包问题?!+并查集一组朋友之中最多只能有一个人去,所以需要在写0-1背包时需要调整for循环的顺序错解:for(int i=1;i<=n;i++) { sum_b=0,sum_w=0; if(pre[i]==i) { for(int j=0;j<vn[i].size();j++) { sum_b+=bn[vn[i][j]]; sum_w+=w原创 2017-09-15 17:20:38 · 346 阅读 · 0 评论 -
ccf-地铁修建
这道题目可以用并查集来做题意:求一条从1到n的路径(不一定是最短的)要求这条路径中最长的边尽量短题解:将边长从小到大排序,按照这个顺序联通这条边的两个端点,直到1和n相连,这时的边长即为所求的结果问题描述 A市有n个交通枢纽,其中1号和n号非常重要,为了加强运输能力,A市决定在1号到n号枢纽间修建一条地铁。 地铁由很多段隧道组成,每段隧道连接两个交通枢纽。经过勘原创 2017-09-16 16:59:33 · 601 阅读 · 0 评论 -
Socks
Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes.原创 2017-11-19 20:46:02 · 614 阅读 · 0 评论 -
L2-024. 部落
L2-024. 部落时间限制120 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者陈越在一个社区里,每个人都有自己的小圈子,还可能同时属于很多不同的朋友圈。我们认为朋友的朋友都算在一个部落里,于是要请你统计一下,在一个原创 2018-03-18 09:20:58 · 131 阅读 · 0 评论 -
L2-020. 功夫传人
L2-020. 功夫传人时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者陈越一门武功能否传承久远并被发扬光大,是要看缘分的。一般来说,师傅传授给徒弟的武功总要打个折扣,于是越往后传,弟子们的功夫就越弱…… 直到某一支的某一代突然出现一个天分特别高的弟子(或者是吃到了灵丹、挖到了特别的秘笈),会将功夫的威力一下子放大N倍 —— 我们称这种弟子为“得道者...原创 2018-03-20 19:04:24 · 162 阅读 · 0 评论 -
Vessels
这道题我错在了细节上如果无法通过下面这组测试样例,那么你需要注意一下我在代码中注释的部分样例如下:25 1021 1 202 2There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels ar原创 2017-07-19 17:52:41 · 268 阅读 · 0 评论 -
小希的迷宫
上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给你,让你帮忙判断她的原创 2017-07-19 14:57:43 · 232 阅读 · 0 评论 -
畅通工程
某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( 注意:两个城市之间可以有多条道路相通,也就是说 3 3原创 2017-07-17 16:20:28 · 221 阅读 · 0 评论 -
Ubiquitous Religions
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 religions students in your university beli原创 2017-07-17 16:32:06 · 176 阅读 · 0 评论 -
Almost Union-Find
并查集的删除操作,可以看做是类似树的懒惰删除,废弃该节点,但不删除,用根结点记录这个并查集的容量和大小,在节点被废弃后,从它的根节点处删除这个节点的数据用一个新的节点替换该节点获得其的属性,代替它加入到新的并查集中可以用一个id[i]数组代替iAlmost Union-FindTime Limit: 1000MS Memory Limit: Unkn原创 2017-07-21 12:25:58 · 286 阅读 · 0 评论 -
Wireless Network
这道题目可能数据比较水这道题目只要是两台电脑的距离小于d就视为在同一并查集中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 unexpect原创 2017-07-21 18:57:05 · 233 阅读 · 0 评论 -
The Suspects
并查集的题目在根节点上维护一下所属节点的个数即可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 o原创 2017-07-21 20:00:23 · 204 阅读 · 0 评论 -
codeup-通信系统
题目描述某市计划建设一个通信系统。按照规划,这个系统包含若干端点,这些端点由通信线缆链接。消息可以在任何一个端点产生,并且只能通过线缆传送。每个端点接收消息后会将消息传送到与其相连的端点,除了那个消息发送过来的端点。如果某个端点是产生消息的端点,那么消息将被传送到与其相连的每一个端点。为了提高传送效率和节约资源,要求当消息在某个端点生成后,其余各个端点均能接收到消息,并且每个端点均不会原创 2017-07-18 19:43:57 · 822 阅读 · 0 评论 -
codeup-How Many Tables
题目描述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 that not all the friends know eac原创 2017-07-18 19:55:41 · 285 阅读 · 0 评论 -
codeup-More is better
题目描述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 certain requirements.Mr Wang selecte原创 2017-07-18 20:50:30 · 293 阅读 · 0 评论 -
蓝桥 历届试题 合根植物
历届试题 合根植物 时间限制:2.0s 内存限制:256.0MB 问题描述 w星球的一个种植园,被分成 m * n 个小格子(东西方向m行,南北方向n列)。每个格子里种了一株合根植物。 这种植物有个特点,它的根可能会沿着南北或东西方向伸展,从而与另一个格子的植物合成为一体。 如果我们告诉你哪些小格子间出现了连根现象,你能说出这个园中一共有多少株合根植物吗?...原创 2019-03-22 21:58:35 · 1212 阅读 · 0 评论