注意在调用 线段树 ask(),change() 时,l,r l,rl,r 的大小关系,应该为 res+=ask(1,id[top[x]],id[x]); ,链顶节点的编号一定小于等于当前节点。
ask(),change()
res+=ask(1,id[top[x]],id[x]);