题意:给出n个卡车,每个卡车的类型是七个字符组成的,一种卡车可以从另一种卡车派生来的,代价是两种卡车间类型不同字符的个数,求出这n中卡车派生的最小代价,n种车有一 种是开始就有的,n-1种是派生出来的。
思路:因为刚开始有一种卡车,所以就是加n-1条把所有车连起来,就是最小生成树了。。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
const int N=2010;
char str[N][10];
int num,f[N];
struct edge
{
int st,ed,w;
}e[N*N];
void addedge(int x,int y,int w)
{
e[num].st=x;e[num]......
阅读全文