动态MST

原谅我真的写不下去了,太难写了,先占坑。

啥时候有比较连续的时间了再写


肯定没用了的无聊代码

#include <cstdio>
#include <vector>
const int N=2e4+10;
const int M=5e4+10;
struct node
{
    int u,v,id;ll w;
    bool friend operator <(node n1,node n2){return n1.w<n2.w;}
}e[M],e0[M];
struct gather
{
    int b[N],h[N];
    int find(int x){return b[x]==x?x:find(b[x]);}
    void merge(int x,int y)
    {
        int ax=find(x),ay=find(y);
        if(h[ax]>h[ay])
            b[ay]=b[ax],s[++tot]=ay;
        else
        {
            b[ay]=b[ax],s[++tot]=ax;
            h[ay]+=h[ay]==h[ax];
        }
    }
}f,d;
void Union(int l,int r,int rp)//[l,r]中的边集右端点rp
{
    for(int u,v,i=1;i<=rp;i++)
    {
        u=e0[i].u,v=e0[i].v;
        f.b[u]=u,f.h[u]=1;
        f.b[v]=v,f.h[v]=1;
    }    
    for(int i=1;i<=rp;i++)
        if(check(l,r,i))//如果是动态边
            f.merge(e0[i].u,e0[i].v);
    sort(e0+1,e0+1+rp);
    for(int u,v,i=1;i<=rp;i++)
    {
        u=e0[i].u,v=e0[i].v;
        if(!check(l,r,i)&&f.find(u)!=f.find(v))
            f.merge(u,v);
    }    
    for(int )
}
void CDQ(int l,int r)
{
    if(l==r)
    {
        
    }
    Union(l,r,rp);
    Delete();
    
}
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=m;i++) scanf("%d%d%lld",&e[i].u,&e[i].v,&e[i].w);
    for(int i=1;i<=q;i++) scanf("%d%lld",id+i,d+i);
    CDQ(1,q);
    return 0;
}
posted @ 2018-09-25 17:37  露迭月  阅读(337)  评论(0编辑  收藏  举报