1.谨防手残 cpp12345678910void build(int p,int l,int r,ll val[N],int rnk[N]){ ... if(l==r){ d[l].v=val[rnk[l]]; return; } ... } 是d[p].v而不是d[l].v