
最小生成树
文章平均质量分 76
xutian_curry
这个作者很懒,什么都没留下…
展开
-
求最小生成树的prime算法
#include<iostream> #include <stdio.h> #include <memory.h> #include <queue> using namespace std; const int IN = 1000000 ; int G[105][105]; int path[105][105]; int M,N; int locos...原创 2018-04-15 21:21:58 · 444 阅读 · 0 评论 -
最小堆+并查集实现最小生成树的kursutra算法
#include <iostream> #include <queue> #include <vector> using namespace std; int N,M; int father[105]; int MST; struct edage { int source,End,length; edage(int ss,int ee,int l...原创 2018-04-15 22:23:27 · 379 阅读 · 0 评论 -
兔子与星空
最小生成树prime算法 注意初始化#include <iostream> #include <memory.h> #include <bits/stdc++.h> const int IN = (1<<28); using namespace std; int G[30][30];//邻接矩阵 int locost[30]; int N; int...原创 2018-05-04 17:44:38 · 524 阅读 · 0 评论 -
poj 1287 Networking
最小生成树分别用prime和kruskal算法实现。prime算法判断是否连通是查看是否加入了n-1条边(即循环是否执行了n-1次)kruskal算法判断是否连通是 最后查看是否所有点都在同一集合内prime算法:#include <iostream> #include <memory.h> using namespace std; const int IN = (...原创 2018-05-06 18:36:59 · 148 阅读 · 0 评论 -
poj 1258 agri-net
裸的最小生成树prime算法比较方便#include <iostream> #include <memory.h> using namespace std; const int IN = (1<<28); int G[105][105]; int locost[105]; int N,M,Cost,flag; void Prime() { locost[...原创 2018-05-06 19:50:42 · 124 阅读 · 0 评论 -
最小生成树 hdu 1879 继续畅通工程
调了将近两个小时,一直tle,从优先级队列改成数组+排序 到改并查集结构,最后发现是给边开的数组不够大。。。长记性了两种形式的kurskal献上第一种#include <iostream> #include <memory.h> #include <queue> #include <stdio.h> using namespace std; cons...原创 2018-05-06 22:09:07 · 240 阅读 · 0 评论 -
poj 2485 highways 记录最小生成树中的最大边
#include <iostream> #include <memory.h> #define IN (1<<28) using namespace std; int kase,N; int G[505][505]; int locost[505], visited[505]; int cost, ans; void prime() { for( int ...原创 2018-05-07 15:18:59 · 169 阅读 · 0 评论 -
poj 1789 trucks 最小生成树
题意:给出n个长度为7的字符串,每个字符串代表一个车,定义车的距离是两个字符串间不同字母的个数,题目要求的数不同的车的距离的最小值,即所求的就是最小生成树注意cin 会超时#include <iostream> #include <memory.h> #include <string> #include <stdio.h> #define IN (1...原创 2018-05-07 15:41:13 · 148 阅读 · 0 评论