题解
传送门
题解
然而要我来说我感觉只是个爆搜啊……
//minamoto
#include<bits/stdc++.h>
#define R register
#define ll long long
#define ls (p<<1)
#define rs (p<<1|1)
#define fp(i,a,b) for(R int i=a,I=b+1;i<I;++i)
#define fd(i,a,b) for(R int i=a,I=b-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){R int res,f=1;R char ch;while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');return res*f;
}
inline char getop(){R char ch;while((ch=getc())>'Z'||ch<'A');return ch;}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R ll x){if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;while(z[++Z]=x%10+48,x/=10);while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int N=2e5+5;
int r[N<<2],mx[N<<2],mn[N<<2],v[N],n,m,x0,ql,qr;ll res,a,b,c;char op;
inline int Rand(){x0=(1ll*100000005*x0+20150609)%998244353;return x0/100;}
inline void ppd(R int p){r[p]^=1,swap(mn[p],mx[p]),mn[p]=100000-mn[p],mx[p]=100000-mx[p];}
inline void pd(R int p){if(r[p])r[p]=0,ppd(ls),ppd(rs);}
inline void upd(R int p){mx[p]=max(mx[ls],mx[rs]),mn[p]=min(mn[ls],mn[rs]);}
void build(int p,int l,int r){if(l==r)return mx[p]=mn[p]=v[l],void();int mid=(l+r)>>1;build(ls,l,mid),build(rs,mid+1,r);upd(p);
}
void update(int p,int l,int r,int x,int t){if(l==r)return mx[p]=mn[p]=t,void();int mid=(l+r)>>1;pd(p);x<=mid?update(ls,l,mid,x,t):update(rs,mid+1,r,x,t);upd(p);
}
void rev(int p,int l,int r){if(ql<=l&&qr>=r)return ppd(p);int mid=(l+r)>>1;pd(p);if(ql<=mid)rev(ls,l,mid);if(qr>mid)rev(rs,mid+1,r);upd(p);
}
inline ll calc(R int x,R int y){return 1ll*x*a+1ll*y*b+1ll*x*y*c;}
void query(int p,int l,int r){int mid=(l+r)>>1;pd(p);if(ql<=l&&qr>=r){if(l==r)return cmax(res,calc(l,mx[p])),void();if(calc(r,mx[rs])>res)query(rs,mid+1,r),void();if(calc(mid,mx[ls])>res)query(ls,l,mid),void();return;}if(ql<=mid)query(ls,l,mid);if(qr>mid)query(rs,mid+1,r);
}
int main(){
// freopen("testdata.in","r",stdin);n=read(),m=read(),x0=read();fp(i,1,n)v[i]=Rand()%100001;build(1,1,n);while(m--){op=getop(),ql=Rand(),qr=Rand();if(op=='C')ql=ql%n+1,qr=qr%100001,update(1,1,n,ql,qr);else{ql=ql%n+1,qr=qr%n+1;if(ql>qr)swap(ql,qr);if(op=='R')rev(1,1,n);else a=read(),b=read(),c=read(),res=0,query(1,1,n),print(res);}}return Ot(),0;
}