#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; #define lc t[x].ch[0] #define rc t[x].ch[1] #define pa t[x].fa typedef long long ll; const int N=3e5+5; inline int read() while(c>='0'&&c<='9') return x*f; } namespace lct { struct meow{int ch[2], fa, rev, sum, w;} t[N]; inline int wh(int x) {return t[pa].ch[1] == x;} inline int isr(int x) {return t[pa].ch[0] != x && t[pa].ch[1] != x;} inline void update(int x) {t[x].sum = t[lc].sum ^ t[rc].sum ^ t[x].w;} inline void rever(int x) {t[x].rev ^= 1; swap(lc, rc);} inline void pushdn(int x) } void pd(int x) inline void rotate(int x) inline void splay(int x) inline void access(int x) { for(int y=0; x; y=x, x=pa) splay(x), rc=y, update(x); } inline void maker(int x) { access(x); splay(x); rever(x); } inline int findr(int x) { access(x); splay(x); while(lc) pushdn(x), x=lc; return x; } inline void link(int x, int y) { maker(x); t[x].fa=y; } inline void cut(int x, int y) { maker(x); access(y); splay(y); t[x].fa = t[y].ch[0] = 0; update(y); } inline void split(int x, int y) { maker(x); access(y); splay(y); } } using lct::findr; int n, Q, op, x, y; int main() }
PLCT检查是什么[Link-Cut-Tree]【学习笔记】
未经允许不得转载:上海聚慕医疗器械有限公司 » PLCT检查是什么[Link-Cut-Tree]【学习笔记】











