求Hack
查看原帖
求Hack
307940
aaaaaaaawsl楼主2023/9/1 21:39

Splay 中有爷爷就转父亲,然后无论如何都转儿子过了。

不开 O2 最慢点不超过 1.5s 求 Hack 或证明为什么是对的。

提交记录

正常写法 :

inline void SPY(int x, int pos){
	while(fa[x] != pos){
		y = fa[x], z = fa[y];
		if(z != pos) rot((t[z][1] == y) ^ (t[y][1] == x) ? x : y);
		rot(x);
	}
	if(!pos) rt = x;
}

这份代码写法

inline void SPY(int x, int pos){
	while(fa[x] != pos){
		y = fa[x], z = fa[y];
		if(z != pos) rot(y);
		rot(x);
	}
	if(!pos) rt = x;
}
2023/9/1 21:39
加载中...