其他分享
首页 > 其他分享> > 建树

建树

作者:互联网

 

 

结构体

struct trees{
    trees *lson,*rson;
    LL v;
}dz[1000010],*root=&dz[0];

 

建树

void build(trees *tree, int l, int r){
    if(l==r){
        tree->v=a[l];
        return ;
    }
    int mid=(l+r)>>1;
    tree->lson=&dz[now++];
    tree->rson=&dz[now++];
    build(tree->lson,l,mid);
    build(tree->rson,mid+1,r);
    tree->v = tree->lson->v + tree->rson->v;
} 

 

标签:int,rson,tree,mid,dz,lson,建树
来源: https://www.cnblogs.com/gogoflower/p/10626746.html