Truck History - poj 1789 (Prim 算法)】的更多相关文章

  Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 20884   Accepted: 8075 Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The compa…
有一个汽车公司有很多年的汽车制造历史,所以他们会有很多的车型,现在有一些历史学者来研究他们的历史,发现他们的汽车编号很有意思都是有7个小写字母组成的,而且这些小写字母具有一些特别的意义,比如说一个汽车是有另外一个汽车演变过来的,他们的字母差了有几个不同的,就说明演变多少年(最多也就7年!!),现在就是求这些汽车的总演变史最少有多少时间. 分析:考虑到是个完全图,应该使用prim算法,因为prim是按照点来的,不过还是喜欢krusal,试一下看看能不能过.. *******************…
链接: http://poj.org/problem?id=1789 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 22133   Accepted: 8581 Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for fu…
题目链接:https://vjudge.net/problem/POJ-1789 思路: 题目意思就是说,给定一些长度为7的字符串,可以把字符串抽象为一个点, 每个点之间的距离就是他们本身字符串与其他字符串字符不同的个数. 之后就是一个最小生成树的板子. #include <stdio.h> #include <iostream> #include <queue> using namespace std; ; const int inf = (int)1e9; ]; i…
#include<iostream> #include<cstring> #include<algorithm> #include<stdio.h> using namespace std; const int INF=0x3f3f3f3f; ; int n; int p[N]; ]; ; struct edge{ int a,b; int w; }e[N*N]; bool cmp(edge a,edge b) { return a.w<b.w; }…
Truck History Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18981   Accepted: 7321 Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for brick…
题目链接: https://vjudge.net/problem/POJ-1789 题目大意: 用一个7位的string代表一个编号,两个编号之间的distance代表这两个编号之间不同字母的个数.一个编号只能由另一个编号"衍生"出来,代价是这两个编号之间相应的distance,现在要找出一个"衍生"方案,使得总代价最小,也就是distance之和最小. 思路: 最小生成树模板题,这里是稠密图,应该用prim算法 直接在原来模板的基础上稍加改动即可 #include…
  Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 44373   Accepted: 18127 Description Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your…
  Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24383   Accepted: 11243 Description The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian…
给定N个字符串,某个字符串转为另一个字符串的花费为他们每一位不相同的字符数. 求最小花费Q. Input 多组输入,以0结束. 保证N不超过2000. Output 每组输出"The highest possible quality is 1/Q.". Sample Input 4 aaaaaaa baaaaaa abaaaaa aabaaaa 0 Sample Output The highest possible quality is 1/3. 由于是完全图,所以用prim 1.s…