void add(ll t){ tree[++num]=t; ll p=num,father=tree[p>>1]; while((p>1)&&father>t){//父节点大于子节点,交换(p不为0) tree[p]=tree[p>>1]; tree[p>>1]=t; p=p>>1; } }
其实就是我的垃圾代码的添加这个函数中,忘记在循环里面更新father的值了,循环末尾添加个father=tree[p>>1];就没事了。 不过真的有人会和我错一样吗