POJ 1861 Network Kruskal优化模板

题目链接:

1861

题意:

又M个点  N条边  求构成最小生成树的最大边   和所有边的两个端点

裸最小生成树    加上了两个优化

1.路径压缩:查找x元素的根节点d时,将x的所有父亲节点全部直接变成根节点的子节点

以减少下次查找的查找时间

2.在并查集  并 的过程中 考虑两个节点谁的子节点多,少的作为子节点

代码:

时间: 2024-10-09 01:49:44

POJ 1861 Network Kruskal优化模板的相关文章

POJ 1861 Network (Kruskal求MST模板题)

Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14103   Accepted: 5528   Special Judge Description Andrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the c

POJ 1861 Network (Kruskal算法+输出的最小生成树里最长的边==最后加入生成树的边权 *【模板】)

Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14021   Accepted: 5484   Special Judge Description Andrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the c

ZOJ 1542 POJ 1861 Network 网络 最小生成树,求最长边,Kruskal算法

题目连接:ZOJ 1542 POJ 1861 Network 网络 Network Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Andrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the company, t

poj 1861 Network (kruskal)

Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13633   Accepted: 5288   Special Judge Description Andrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the c

poj 1861 Network

Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13260   Accepted: 5119   Special Judge Description Andrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the c

poj 1861 Network 解题报告

Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16171   Accepted: 6417   Special Judge Description Andrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the c

POJ 1861 ——Network——————【最小瓶颈生成树】

Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15268   Accepted: 5987   Special Judge Description Andrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the c

ZOJ 1586 QS Network prim优化模板

链接: 1586 题意: 有一个N X N的网络,每两个点都有边相连,边的权值用邻接矩阵输入,每个点也有一个权值,当它们之间的那条边被选取时,需要加上两个点的权值.求这个网络的最小生成树. 直接套用prim算法的模板 其中用到一个节约内存的优化 将lowdistance 和visit 两个数组 结合起来 如果访问过lowdistance改成-1即可 另外该题中边的权值应为边本身的权值加上两端点的权值. #include<iostream> #include<cstdio> #inc

POJ 1861 Network(隐含最小生成树 打印方案)

题意   求n个点m条边的图的连通子图中最长边的最小值 实际上就是求最小生成树中的最长边  因为最小生成树的最长边肯定是所有生成树中最长边最小的  那么就也变成了最小生成树了  不要被样例坑到了  样例并不是最佳方案  只是最长边与最小生成树的最长边相等  题目是特判  直接用最小生成树做就行 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N =