
最小生成树
文章平均质量分 65
acmdream
我是福建某高校2013级在校生,学业之余喜欢研究算法。
展开
-
HDU 1102(最小生成树)
题意:给一个图,以及已知一些边已经存在,求除了给出的这些边,至少需要多长的边才能使所有结点相连接。 kruskal:#include #include #include using namespace std;struct edge{ int u, v, w; edge() {} edge(int _u, int _v, int _原创 2014-01-13 13:49:26 · 626 阅读 · 0 评论 -
hdu 1160(最小生成树)
题意:给出一个数n,接下来有n个行,每行给出一个点的x坐标和y坐标,求连接每个点的最小消耗。 #include#include#includeint n;double dis[101][101];int vis[101];double lowcost[101];int inf=1000000;typedef struct原创 2014-01-14 22:46:35 · 567 阅读 · 0 评论 -
HDU 1233(最小生成树,并查集)
这里使用kruskal: #include #include #include using namespace std;struct edge{ int u, v, w; edge() {} edge(int _u, int _v, int _w) : u(_u), v(_v), w(_w) {} bool operator原创 2014-01-15 21:08:20 · 676 阅读 · 0 评论 -
HDU 1232(最小生成树;并查集)
题意:如题。 最小生成树建模方法:已有的边的花费为0,不存在的边花费为1,求最小生成树。 #include#includeusing namespace std;#define Inf 0x7fffffffint map[1005][1005];int Prim(int s){ int i,j,k,dis[1005],temp,flag,ans=0原创 2014-01-15 21:05:12 · 886 阅读 · 0 评论