l i n k \textcolor{pink}{link} link
分析:
树剖暴力修改
修改时统计链上下部分的轻重划分 查询时判链上下端的值
可维护 t i m tim tim时间戳优化 总时间 O ( T q l o g 2 n ) O(Tq~log^2n) O(Tq log2n)
要大力卡常
CODE:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define inf 0x7fffffff
#define Inf 1e18
using namespace std;
typedef long long ll;
const int N=1e5+5;
int T,n,Q,tot,head[N],id;
int fa[N],dep[N],top[N],dfn[N],size[N],son[N];
struct node{
int to,next;
}a[N<<1];
struct SegmentTree{
int l,r,len,tag,tim;
}tree[N<<2];
inline void add(int x,int y)
{
a[++tot]=(node){
y,head[x]};
head[x]=tot;
}
inline void calc(int x,int flag,int tim)
{
if(flag) tree[x].tag=flag;
if(tim) tree[x].tim=tim;
if(flag==1) tree[x].len=tree[x].r-tree[x