poj 1789】的更多相关文章

链接:Truck History - POJ 1789 - Virtual Judge  https://vjudge.net/problem/POJ-1789 题意:先给出一个n,代表接下来字符串的个数,接下来n个字符串,每个字符串长度为7,没有完全相同的字符串,字符串之间的距离是两个字符串里不同字符的个数(相同位置两两对比),然后求出从某个点到其他点距离和的最小值(分子一直是1,Q越小,1/Q越大),其实就是叫我们求出最小生成树,先字符串两两相比建图,然后求最小生成树. #include<i…
题目传送门 题意:给出n个长度为7的字符串,一个字符串到另一个的距离为不同的字符数,问所有连通的最小代价是多少 分析:Kuskal/Prim: 先用并查集做,简单好写,然而效率并不高,稠密图应该用Prim而且要用邻接矩阵,邻接表的效率也不高.裸题但题目有点坑爹:( Kruskal: #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <…
 POJ 1789 -- Truck History Prim求分母的最小.即求最小生成树 #include<iostream> #include<cstring> #include<algorithm> using namespace std; + ; ; int n;//有几个卡车 ]; int d[maxn];//记录编号的数值 int Edge[maxn][maxn]; int dist[maxn]; void prim() { ; //加入源点 dist[]…
题目链接:POJ 1789 Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a truck. The code is simply…
http://poj.org/problem?id=1789 这是一道图论的题,个人觉得和那个POJ1258是差不多的,就是多了一步,题目难以读懂 题目的意思:就是给你一群字符串要你找字符串对应的字符不同,使得这个字符串与其他字符串不同 举个例子,不然题目也确实看不懂, 4 a b a a a b a b a a a a b a b a a b b a b a b a a a a a 以第一个为主的与其他行不同的字母数分别为:0 2 6 1 以第二个为主的与其他行不同的字母数分别为:2 0 4…
题目连接 http://poj.org/problem?id=1789 Truck History Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each…
模板题 题目:http://poj.org/problem?id=1789 题意:有n个型号,每个型号有7个字母代表其型号,每个型号之间的差异是他们字符串中对应字母不同的个数d[ta,tb]代表a,b之间的差异数问1/Σ(to,td)d(to,td)最大值 prime: #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack>…
主题链接:http://poj.org/problem?id=1789 思维:一个一个点,每两行之间不懂得字符个数就看做是权值.然后用kruskal算法计算出最小生成树 我写了两个代码一个是用优先队列写的.可是超时啦,不知道为什么.希望有人能够解答.后面用的数组sort排序然后才AC. code: 数组sort排序AC代码: #include<cstdio> #include<queue> #include<algorithm> #include<iostream…
题目链接:http://poj.org/problem?id=1789 Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a truck. The code…
链接: 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…