码迷,mamicode.com
首页 >  
搜索关键字:hdu1102    ( 15个结果
【并查集 最小生成树】POJ2421&&HDU1102:Constructing Roads
Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each oth ...
分类:其他好文   时间:2018-02-23 18:55:22    阅读次数:251
hdu1102 Constructing Roads 【最小生成树】【prime】
Constructing Roads Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24721 Accepted Submission(s): ...
分类:其他好文   时间:2017-10-30 19:43:27    阅读次数:163
hdu1102 Constructing Roads 基础最小生成树
1 //克鲁斯卡尔(最小生成树) 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn = 100005; 8 int n, t; 9 struct node 10 { 11 int bagin, end... ...
分类:其他好文   时间:2017-07-21 22:05:47    阅读次数:140
HDU1102--Constructing Roads(最小生成树)
Problem Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to ...
分类:其他好文   时间:2016-12-29 23:19:11    阅读次数:227
HDU1102 最小生成树prim算法
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1102 题意:给出任意两个城市之间建一条路的时间,给出哪些城市之间已经建好,问最少还要多少时间使所有的城市连通? 思路:已经建好的城市之间需要的时间设为0,就是求最小生成树的权值和了。 顺便复习一下pri
分类:编程语言   时间:2016-03-19 12:33:49    阅读次数:207
hdu1102(最小生成树)
题意为将所有点连起来,但是有些边已经帮你连好了,要求你将剩下的连起来形成最小生成树。因为一些点已经连起来了,所以应该选用kruskal算法。虽然这道题的图是按照邻接矩阵给出的,但选用prim算法的话,实现起来反而不容易还容易出错,倒不如自己对输入进行一些加工,然后选取kruskal算法。#inclu...
分类:其他好文   时间:2015-08-21 21:11:13    阅读次数:127
HDU1102 Constructing Roads (最小生成树)
Prim算法求最小生成树#include #include #include using namespace std; const int N=110; const int INF=0x3f3f3f3f; int n,ans; int map[N][N],dis[N],vis[N]; void Prim(){ int i; for(i=1;i<=n;i++){ ...
分类:其他好文   时间:2015-05-27 13:54:36    阅读次数:150
千找万找,终于找到错误了
HDU1102 (最小生成树)RE-栈溢出 了5遍; 1 int find_set(int x) 2 { 3 if(F[x] == x) 4 return x; 5 else 6 return find_set(F[x]); 7 } 8 int mai...
分类:其他好文   时间:2015-05-25 20:15:43    阅读次数:99
hdu 1102 Constructing Roads 最小生成树Prim算法AC 水~~~
Problem Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if and only if there is a road between A and B, or t...
分类:编程语言   时间:2015-02-23 15:31:07    阅读次数:231
HDU1102 Constructing Roads【Prim】
题目大意:先给你N个村庄之间距离,用矩阵表示。再告诉你S个已经建好的路。 求再建多少距离的路,能实现N个村庄全部联通。 思路:用Prim算法来求最小生成树,已经建好的路就看做是路连接的两个村庄 之间距离为0。图建好后直接用Prim模板就可以了。...
分类:其他好文   时间:2015-01-03 18:39:03    阅读次数:187
15条   1 2 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!