这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 | |||
2020-2021:teams:hotpot:lotk_树套树 [2020/05/08 16:48] lotk |
2020-2021:teams:hotpot:lotk_树套树 [2020/05/08 16:53] (当前版本) lotk [平衡树套线段树(替罪羊)] |
||
---|---|---|---|
行 624: | 行 624: | ||
query(root,l,r);k--; | query(root,l,r);k--; | ||
int L=0,R=70000; | int L=0,R=70000; | ||
- | unt n=vectr.size(); | ||
while(L<R){ | while(L<R){ | ||
int mid=(L+R)>>1; | int mid=(L+R)>>1; | ||
行 631: | 行 630: | ||
for(auto x:vecp)if(L<=w[x]&&w[x]<=mid)++tot; | for(auto x:vecp)if(L<=w[x]&&w[x]<=mid)++tot; | ||
if(tot>k){ | if(tot>k){ | ||
- | for(unt i=0;i<n;++i)vectr[i]=ls(vectr[i]); | + | for(auto &x:vectr)x=ls(x); |
R=mid; | R=mid; | ||
} | } | ||
else { | else { | ||
- | for(unt i=0;i<n;++i)vectr[i]=rs(vectr[i]); | + | for(auto &x:vectr)x=rs(x); |
L=mid+1;k-=tot; | L=mid+1;k-=tot; | ||
} | } |