CF620E New Year Tree


\(Link\)

题意略。

首先只有子树操作,于是我们把这棵树拍成欧拉序。

然后把每个位置的颜色状压一下,就变成了区间推平和区间按位或。

然后谁都会的线段树。

\(Code:\)

// Problem: E. New Year Tree
// Contest: Codeforces - Educational Codeforces Round 6
// URL: https://codeforces.com/contest/620/problem/E
// Memory Limit: 256 MB
// Time Limit: 3000 ms
// Author: jimmyywang

#include
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll rd() {
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d rd()
#define pb push_back
ll n,m;
ll ls(ll p){return p<<1;}
ll rs(ll p){return p<<1|1;}
ll t[800010<<2];
ll tg[800010<<2];
void upd(ll p){t[p]=t[ls(p)]|t[rs(p)];}
void pd(ll p){
	if(!tg[p])return;
	tg[ls(p)]=tg[rs(p)]=t[ls(p)]=t[rs(p)]=tg[p];
	tg[p]=0;
}
void ch(ll l,ll r,ll p,ll L,ll R,ll k){
	if(L<=l&&r<=R){tg[p]=t[p]=k;return;}
	pd(p);ll mid=(l+r)>>1;
	if(mid>=L)ch(l,mid,ls(p),L,R,k);
	if(mid>1,ans=0;
	if(mid>=L)ans|=ask(l,mid,ls(p),L,R);
	if(mide[400010];
ll l[400010],r[400010];
void dfs(ll u,ll fa){ 
	l[u]=++cnt;
	for(int i=0;i