陈奕迅一定要比我幸福:最小生成树1233

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 03:34:29
#include#include#include#include#include
using namespace std;/*typedef struct node{  int a;  int b;  int number;  int length;};node [100];*/int p[5002];int u[100],v[100],w[100];int cmp(const int i,const int j){    return w[i]

别人的、、#include #include#include
using namespace std;struct node{  int x,y;    int z;}shu[50000];int p[50000];int findx(int x){/*    int r;    r=x;    while(r!=p[r])    {        r=p[r];    } p[r]=r;    return r;*/    if(x==p[x])        return x;    p[x]=findx(p[x]);    return p[x];}int connect(int x,int y){    int q,w;    q=findx(x);    w=findx(y);    /*    if(q!=w)    {        if(q>w)        {p[q]=w;}        else {p[w]=q;}        return 1;    }    else return 0;*/    if(q==w)        return 0;    p[w]=q;    return 1;}/*int cmp(const void *aa,const void*bb){      return((*(struct node*)aa).z-(*(struct node*)bb).z);
}*/int cmp(node a,node b){    return a.z
        return 0;}