警钟撅烂

P3391 【模板】文艺平衡树

Zikl @ 2023-03-12 20:53:57

对的

int build_tree(int x,int l,int r){
    if(l>r) return 0;
    int mid=(l+r)>>1,now=++tot;
    t[now].ch[0]=t[now].ch[1]=0;
    t[now].val=a[mid];
    t[now].fa=x;
    t[now].tag=0;
    t[now].ch[0]=build_tree(now,l,mid-1);
    t[now].ch[1]=build_tree(now,mid+1,r); 
    maintain(now);
    return now;
} 

错误的

int build_tree(int x,int l,int r){
    if(l>r) return 0;
    int mid=(l+r)>>1,now=++tot;
    t[now].ch[0]=t[now].ch[1]=0;
    t[now].val=a[mid];
    t[now].fa=x;
    t[now].tag=0;
    t[now].ch[0]=build_tree(now,l,mid-1);
    t[now].ch[1]=build_tree(now,mid+1,r); 
    maintain(now);
    return tot;
} 

by langligelang @ 2023-03-12 20:57:16

好啊,我也来一个

for (int i = 1; i <= n; i++) pos[i] = (i-1)/n + 1;

by Ciallos @ 2023-07-25 13:02:27

蒟蒻求教,上下两个有什么区别吗?


by Zikl @ 2023-09-23 22:40:35

return tot;
return now;

@Ciallos


|