一次AC。吼啊。
BZOJ权限QAQ
区间加和乘打标记,区间乘x就是区间移动,平衡树解决即可。
查询直接遍历一遍然后算出来
// It is made by XZZ
#include<cstdio>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#define il inline
#define rg register
#define vd void
#define sta static
#define int long long
#define mod 20130426
#define pr pair<int,int>
using namespace std;
il int gi(){
rg int x=0,f=1;rg char ch=getchar();
while(ch<'0'||ch>'9')f=ch=='-'?-1:f,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*f;
}
const int maxn=200010;
int rt=0,ran[maxn],ls[maxn],rs[maxn],num[maxn],add[maxn],mul[maxn],siz[maxn];
il vd Mul(const int&x,const int&y){if(x)num[x]=num[x]*y%mod,mul[x]=mul[x]*y%mod,add[x]=add[x]*y%mod;}
il vd Add(const int&x,const int&y){if(x)num[x]=(num[x]+y)%mod,add[x]=(add[x]+y)%mod;}
il vd down(const int&x){
if(mul[x]^1)Mul(ls[x],mul[x]),Mul(rs[x],mul[x]),mul[x]=1;
if(add[x]) Add(ls[x],add[x]),Add(rs[x],add[x]),add[x]=0;
}
il vd upd(const int&x){siz[x]=siz[ls[x]]+siz[rs[x]]+1;}
il int merge(int x,int y){
if(x==0||y==0){down(x|y);return x|y;}
if(ran[x]<ran[y]){down(x),rs[x]=merge(rs[x],y),upd(x);return x;}
else {down(y),ls[y]=merge(x,ls[y]),upd(y);return y;}
}
il pr split(int x,int k){
if(!x)return make_pair(0,0);
down(x);
pr p=make_pair(ls[x],rs[x]);
if(k==siz[ls[x]]){ls[x]=0,upd(x);p.second=x;return p;}
if(k==siz[ls[x]]+1){rs[x]=0,upd(x);p.first=x;return p;}
if(k<siz[ls[x]]){p=split(ls[x],k);ls[x]=p.second;upd(x);p.second=x;return p;}
else {p=split(rs[x],k-siz[ls[x]]-1);rs[x]=p.first;upd(x);p.first=x;return p;}
}
int s[maxn];
il vd dfs(int x){
down(x);upd(x);
if(ls[x])dfs(ls[x]);
s[++s[0]]=num[x];
if(rs[x])dfs(rs[x]);
}
main(){
int n=200001,m=gi(),l,r;char opt[10];
srand(time(NULL));ran[0]=rand()+1;
for(rg int i=1;i<=n;++i)ran[i]=(ran[i-1]*19260817)&2147483647;
for(rg int i=1;i<=n;++i)siz[i]=1,mul[i]=1,add[i]=0,rt=merge(rt,i);
pr a,b,c,d;
while(m--){
scanf("%s",opt);
if(opt[0]=='m')
if(opt[3]=='x'){
l=gi()+1,r=gi()+1;
a=split(rt,l-1);b=split(a.second,r-l),c=split(b.second,1),d=split(c.second,1);
num[d.first]+=num[c.first],num[c.first]=0;
rt=merge(merge(a.first,c.first),merge(b.first,merge(d.first,d.second)));
}else{
l=gi()+1,r=gi()+1;
a=split(rt,l-1),b=split(a.second,r-l+1);
Mul(b.first,gi());
rt=merge(a.first,merge(b.first,b.second));
}
else if(opt[0]=='a'){
l=gi()+1,r=gi()+1;
a=split(rt,l-1),b=split(a.second,r-l+1);
Add(b.first,gi());
rt=merge(a.first,merge(b.first,b.second));
}else{
r=gi(),l=1;int ans=0;
s[0]=0;
dfs(rt);
for(rg int i=1;i<=n;++i,l=l*r%mod)
ans=(ans+s[i]*l%mod)%mod;
printf("%lld\n",ans);
}
}
return 0;
}