萌新刚学C++,有点问题
查看原帖
萌新刚学C++,有点问题
520333
SunnyYuan楼主2023/7/8 22:46

在平衡树中,

是通过懒标记来实现旋转,

在pushdown时,为什么

swap(tr[u].l, tr[u].r);

是对的,而

swap(tr[tr[u].l], tr[tr[u].r])

却是错的?

AC代码中的pushdown:

void pushdown(int u) {
	if (tr[u].tag) {
		tr[tr[u].l].tag ^= 1;
		tr[tr[u].r].tag ^= 1;
		swap(tr[u].l, tr[u].r);
		tr[u].tag ^= 1;
	}
}
2023/7/8 22:46
加载中...