结构体
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; }