# 宏定义的玄学错误，大佬们来看看

@Appleuiy  2020-02-02 14:10 回复

#include<bits/stdc++.h>
using namespace std;

#define R unsigned int
#define ls(x) c[x][0]
#define rs(x) c[x][1]
**#define pushup(x) sum[x]=(sum[rs(x)]+sum[ls(x)]+a[x])%P,sz[x]=sz[ls(x)]+sz[rs(x)]+1**
#define ntroot(x) (ls(f[x])==x||rs(f[x])==x)
#define id(x) (rs(f[x])==x)
#define mul(x) x*=c;x%=P
const int N=100006;
const int P=51061;
R sum[N],a[N],lm[N],la[N],sz[N],c[N][2],f[N],r[N];

void in(R &ans){
ans=0;char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c<='9'&&c>='0')ans=ans*10+c-'0',c=getchar();
}

}
void pushmul(R x,R c){
mul(la[x]);mul(sum[x]);mul(a[x]);mul(lm[x]);
}
void pushur(R x){
swap(ls(x),rs(x));r[x]^=1;
}
void pushdown(R x){
if(lm[x]!=1)pushmul(ls(x),lm[x]),pushmul(rs(x),lm[x]),lm[x]=1;
if(r[x]){
if(rs(x))pushur(rs(x));if(ls(x))pushur(ls(x));r[x]=0;
}
}
void roate(R x){
int y=f[x],z=f[y],k=id(x),w=c[x][!k];
if(ntroot(y))c[z][id(y)]=x;c[x][!k]=y;c[y][k]=w;
if(w)f[w]=y;f[y]=x;f[x]=z;
pushup(y);
}
void pushall(R x){
if(ntroot(x))pushall(f[x]);
pushdown(x);
}
void spaly(R x){
pushall(x);
while(ntroot(x)){
R y=f[x],z=f[y];
if(ntroot(y))
roate(id(x)==id(y)?y:x);
roate(x);
}
pushup(x);
}

void access(R x){
for(int y=0;x;x=f[y=x])
spaly(x),rs(x)=y,pushup(x);
}
void makeroot(R x){
access(x);spaly(x);pushur(x);
}
void split(R x,R y){
makeroot(x);access(y);spaly(y);
}
makeroot(x);f[x]=y;
}
void cut(R x,R y){
split(x,y);ls(y)=f[x]=0;
}

int main(){
freopen("aa.in","r",stdin);
freopen("aa.out","w",stdout);
R n,m,u,v,u1,v1,k,x,y;
in(n);in(m);

for(int i=1;i<=n;i++)sz[i]=a[i]=lm[i]=1;
for(int i=1;i<n;i++){
}
char opt[3];
while(m--){
scanf("%s",opt);
in(u);in(v);
switch(opt[0]){
case '*':in(k);split(u,v);pushmul(v,k);break;
case '/':split(u,v);printf("%d\n",sum[v]);break;
}
}
}

@qwqqwq_qwqqwq 2020-02-02 14:19 回复 举报

@御坂20001号  2020-02-02 15:09 回复 举报
#define ad(x) x * 2
cout<<ad(x + 2)<<endl;

x=2时，你觉得会输出多少？