POJ 3237 Tree
POJ_3237 用link-cut-tree或者树链剖分都可以,为了处理negate操作,出了lazy标记外可以做两个标记max、min,在执行negate时,令max=-min、min=-max即可。 #include<stdio.h> #include<string.h> #define MAXD 100010 #define MAXM 200010 #define INF 0x7fffffff int N, q[MAXD], first[MAXD], e, next[MAXM], v[MAXM], w[MAXM], dep[MAXD]; struct Edge { int x, y, z; }edge[MAXD]; struct Splay { int pre, ls, rs, neg, key, max, min; bool root; void update(); void pushdown(); void zig(int ); void zag(int ); void splay(int ); void renew() { root = true; pre = ls = rs = 0; neg = 0; } }sp[MAXD]; int Max(int x, int y) { return x > y ? x : y; } int Min(int x, int y)