摘要: http://poj.org/problem?id=1751 题意:给出n个城镇(编号1-N)的坐标,m条已经建好的边(无向)。问需要在哪些城镇之间建边,使得n个城镇联通,且代价(距离)最小,输出所以需要在两城镇间建边的编号。 解法:kruskal 注意:在已经建好的边中不一定就是最小生成树中所需要 阅读全文
posted @ 2019-08-17 22:06 无名菜鸟1 阅读(181) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3790 题意:给出两个权值的图,距离和价值,距离优先于价值。求u、v间最短路径。 #include<bits/stdc++.h> using namespace std; typedef long long ll 阅读全文
posted @ 2019-08-17 11:29 无名菜鸟1 阅读(333) 评论(0) 推荐(0)
摘要: https://vjudge.net/contest/299441#problem/A 题意:给出图,求1到n点的最短距离。 https://www.cnblogs.com/thousfeet/p/9229395.html Dijkstra:时间复杂度为O(n^2) 单源最短路径:1、所有节点分为两 阅读全文
posted @ 2019-08-17 10:19 无名菜鸟1 阅读(599) 评论(0) 推荐(0)