9.23 D
鉴于 5k 和 int_R 等大神都认为这道题 80pts 档是一个普通的线段树,作为一个线段树狂热爱好者果断尝试,但在打出 30 行的 pushup 后蚌埠住了,但还是想切掉,所以暂存一下,什么时候打出来什么时候删置顶。
进度展示:
- 9.23 20:30 正式立项,pushup;
- 9.23 21:30 按 int_R 的提示改成了用结构体存储,开两棵树分别记录正连续段和负连续段的相关值;
- 9.24 06:56 打完操作一的 upd 和 pushdown,能跑出结果;
- 9.24 21:38 打完除操作四以外全部其他操作并过编,提交 0pts;
- 9.25 21:28 获得了对排,发现问题出现在查询时不同区间没有合并,调不动了;
- 9.26 17:00 已经过了只有一种修改操作的点共 40pts,问题出现在 pushdown 的顺序上,\(\Huge{改了然后电脑似了}\);
你们要是能发现问题记得说啊,
题面
终于有分了!虽然 5s 时限下暴力能拿的更多吧
#include<bits/stdc++.h>
#define fo(x,y,z) for(register int (x) = (y);(x)<=(z);(x)++)
#define fu(x,y,z) for(register int (x) = (y);(x)>=(z);(x)--)
using namespace std;
typedef long long ll;
#define lx ll
inline lx qr()
{
char ch = getchar();lx x = 0 , f = 1;
for(;ch<'0'||ch>'9';ch = getchar()) if(ch == '-') f = -1;
for(;ch>= '0' && ch<= '9';ch = getchar()) x = (x<<3) + (x<<1) + (ch^48);
return x*f;
}
#undef lx
#define qr qr()
#define pii pair<int , int>
#define fi first
#define se second
const int Ratio = 0;
const int N = 2e5 + 5;
const int mod = 998244353;
int n , m;
int a[N];
// segment tree
// int llen[N<<2]/*左连续正长度*/ , rlen[N<<2] , zgs[N<<2]/*正连续段个数*/;
// unsigned lji[N<<2] , rji[N<<2] , lv1[N<<2] , rv1[N<<2] , v1[N<<2] , v2[N<<2] , v3[N<<2] , v4[N<<2];
// bool man[N<<2];// 整段为正
struct rmm
{
int llen , rlen , zgs;
int lazy1 , lazy2 , lazy3;
unsigned lji , rji , lv1 , rv1 , v1 , v2 , v3 , v4 , aji;
bool man;
void Wclear(){llen = rlen = zgs = lazy1 = lazy2 = lazy3 = 0;lji = rji = lv1 = rv1 = v1 = v2 = v3 = v4 = 0;man = 0;}
}A[N<<2] , B[N<<2];
namespace Wisadel
{
unsigned Wqp(unsigned x , int y)
{
unsigned res = 1;
while(y){if(y & 1) res = res * x;x = x * x;y >>= 1;}
return res;
}
#define ls (rt<<1)
#define rs (rt<<1|1)
#define mid ((l + r)>>1)
void WpushupA(int rt)
{
// return;
B[rt].aji = A[rt].aji = A[ls].aji * A[rs].aji;
if(A[ls].man && A[rs].man) A[rt].llen = A[rt].rlen = A[ls].llen + A[rs].rlen ,
A[rt].lji = A[rt].rji = A[ls].lji * A[rs].rji , A[rt].man = 1;
else if(!A[ls].man && A[rs].man) A[rt].llen = A[ls].llen , A[rt].lji = A[ls].lji ,
A[rt].rlen = A[rs].rlen + A[ls].rlen , A[rt].rji = A[rs].rji * (A[ls].rlen ? A[ls].rji : 1) , A[rt].man = 0;
else if(A[ls].man && !A[rs].man) A[rt].rlen = A[rs].rlen , A[rt].rji = A[rs].rji ,
A[rt].llen = A[ls].llen + A[rs].llen , A[rt].lji = A[ls].lji * (A[rs].llen ? A[rs].lji : 1) , A[rt].man = 0;
else A[rt].llen = A[ls].llen , A[rt].rlen = A[rs].rlen , A[rt].lji = A[ls].lji , A[rt].rji = A[rs].rji , A[rt].man = 0;
if(A[ls].rlen && A[rs].llen) A[rt].zgs = A[ls].zgs + A[rs].zgs - 1;
else A[rt].zgs = A[ls].zgs + A[rs].zgs;
A[rt].lv1 = A[rt].llen * A[rt].lji , A[rt].rv1 = A[rt].rlen * A[rt].rji;
if(A[ls].man && A[rs].man) A[rt].v1 = A[rt].v2 = A[rt].v3 = A[rt].v4 = A[ls].rji * A[rs].lji * (A[ls].rlen + A[rs].llen);
else if(!A[rs].llen || !A[ls].rlen)
{// 没有合并块
A[rt].v1 = A[ls].v1 + A[rs].v1;
// if(rt==2) cout<<A[ls].v2<<' '<<A[rs].v2<<' '<<A[rs].v1<<' '<<A[ls].zgs<<endl;
A[rt].v2 = A[ls].v2 + A[rs].v2 + A[rs].v1 * A[ls].zgs;
A[rt].v3 = A[ls].v3 + A[rs].v3 + A[ls].v1 * A[rs].zgs;
A[rt].v4 = A[ls].v4 + A[rs].v4 + A[rs].zgs * A[ls].v2 + A[ls].zgs * A[rs].v3;
}
else
{
A[rt].v1 = A[ls].v1 + A[rs].v1 - A[ls].rv1 - A[rs].lv1 + A[ls].rji * A[rs].lji * (A[ls].rlen + A[rs].llen);
A[rt].v2 = A[ls].v2 + A[rs].v2 - A[ls].rv1 * A[ls].zgs - A[rs].lv1 + A[ls].rji * A[rs].lji * (A[ls].rlen + A[rs].llen) * A[ls].zgs + (A[rs].v1 - A[rs].lv1) * (A[ls].zgs - 1);
A[rt].v3 = A[ls].v3 + A[rs].v3 - A[ls].rv1 - A[rs].lv1 * A[rs].zgs + A[ls].rji * A[rs].lji * (A[ls].rlen + A[rs].llen) * A[rs].zgs + (A[ls].v1 - A[ls].rv1) * (A[rs].zgs - 1);
A[rt].v4 = A[ls].v4 + A[rs].v4 - A[ls].rv1 * A[ls].zgs - A[rs].lv1 * A[rs].zgs + (A[rs].zgs - 1) * (A[ls].v2 - A[ls].rji * A[ls].rlen * A[ls].zgs) + (A[ls].zgs - 1) * (A[rs].v3 - A[rs].lji * A[rs].llen * A[rs].zgs) + A[ls].rji * A[rs].lji * (A[ls].rlen + A[rs].llen) * (A[ls].zgs) * (A[rs].zgs);
}
}
void WpushupB(int rt)
{
// return;
A[rt].aji = B[rt].aji = B[ls].aji * B[rs].aji;
if(B[ls].man && B[rs].man) B[rt].llen = B[rt].rlen = B[ls].llen + B[rs].rlen ,
B[rt].lji = B[rt].rji = B[ls].lji * B[rs].rji , B[rt].man = 1;
else if(!B[ls].man && B[rs].man) B[rt].llen = B[ls].llen , B[rt].lji = B[ls].lji ,
B[rt].rlen = B[rs].rlen + B[ls].rlen , B[rt].rji = B[rs].rji * (B[ls].rlen ? B[ls].rji : 1) , B[rt].man = 0;
else if(B[ls].man && !B[rs].man) B[rt].rlen = B[rs].rlen , B[rt].rji = B[rs].rji ,
B[rt].llen = B[ls].llen + B[rs].llen , B[rt].lji = B[ls].lji * (B[rs].llen ? B[rs].lji : 1) , B[rt].man = 0;
else B[rt].llen = B[ls].llen , B[rt].rlen = B[rs].rlen , B[rt].lji = B[ls].lji , B[rt].rji = B[rs].rji , B[rt].man = 0;
if(B[ls].rlen && B[rs].llen) B[rt].zgs = B[ls].zgs + B[rs].zgs - 1;
else B[rt].zgs = B[ls].zgs + B[rs].zgs;
B[rt].lv1 = B[rt].llen * B[rt].lji , B[rt].rv1 = B[rt].rlen * B[rt].rji;
if(B[ls].man && B[rs].man) B[rt].v1 = B[rt].v2 = B[rt].v3 = B[rt].v4 = B[ls].rji * B[rs].lji * (B[ls].rlen + B[rs].llen);
else if(!B[rs].llen || !B[ls].rlen)
{// 没有合并块
B[rt].v1 = B[ls].v1 + B[rs].v1;
B[rt].v2 = B[ls].v2 + B[rs].v2 + B[rs].v1 * B[ls].zgs;
B[rt].v3 = B[ls].v3 + B[rs].v3 + B[ls].v1 * B[rs].zgs;
B[rt].v4 = B[ls].v4 + B[rs].v4 + B[rs].zgs * B[ls].v2 + B[ls].zgs * B[rs].v3;
}
else
{
B[rt].v1 = B[ls].v1 + B[rs].v1 - B[ls].rv1 - B[rs].lv1 + B[ls].rji * B[rs].lji * (B[ls].rlen + B[rs].llen);
B[rt].v2 = B[ls].v2 + B[rs].v2 - B[ls].rv1 * B[ls].zgs - B[rs].lv1 + B[ls].rji * B[rs].lji * (B[ls].rlen + B[rs].llen) * B[ls].zgs + (B[rs].v1 - B[rs].lv1) * (B[ls].zgs - 1);
B[rt].v3 = B[ls].v3 + B[rs].v3 - B[ls].rv1 - B[rs].lv1 * B[rs].zgs + B[ls].rji * B[rs].lji * (B[ls].rlen + B[rs].llen) * B[rs].zgs + (B[ls].v1 - B[ls].rv1) * (B[rs].zgs - 1);
B[rt].v4 = B[ls].v4 + B[rs].v4 - B[ls].rv1 * B[ls].zgs - B[rs].lv1 * B[rs].zgs + (B[rs].zgs - 1) * (B[ls].v2 - B[ls].rji * B[ls].rlen * B[ls].zgs) + (B[ls].zgs - 1) * (B[rs].v3 - B[rs].lji * B[rs].llen * B[rs].zgs) + B[ls].rji * B[rs].lji * (B[ls].rlen + B[rs].llen) * (B[ls].zgs) * (B[rs].zgs);
}
}
void WpushdownA1(int rt , int l , int r)
{
// cout<<"Apd1"<<l<<' '<<r<<endl;
A[ls].llen = A[ls].rlen = mid - l + 1;
A[rs].llen = A[rs].rlen = r - mid;
A[ls].zgs = A[rs].zgs = 1;
B[ls].Wclear() , B[rs].Wclear();
A[ls].lazy1 = A[rs].lazy1 = A[rt].lazy1;
A[ls].lazy2 = A[ls].lazy3 = A[rs].lazy2 = A[rs].lazy3 = 0;
A[ls].man = A[rs].man = 1;
A[ls].aji = B[ls].aji = A[ls].lji = A[ls].rji = Wqp(A[rt].lazy1 , mid - l + 1);
A[rs].aji = B[rs].aji = A[rs].lji = A[rs].rji = Wqp(A[rt].lazy1 , r - mid);
// if(l==6&&r==10) cout<<"超市"<<A[rs].lji<<' '<<A[rs].llen<<endl;
A[ls].lv1 = A[ls].rv1 = A[ls].v1 = A[ls].v2 = A[ls].v3 = A[ls].v4 = (unsigned) A[ls].llen*A[ls].lji;
A[rs].lv1 = A[rs].rv1 = A[rs].v1 = A[rs].v2 = A[rs].v3 = A[rs].v4 = (unsigned) A[rs].llen*A[rs].lji;
A[rt].lazy1 = 0;
}
void WpushdownB1(int rt , int l , int r)
{
// cout<<"Bpd"<<l<<' '<<r<<endl;
B[ls].llen = B[ls].rlen = mid - l + 1;
B[rs].llen = B[rs].rlen = r - mid;
B[ls].zgs = B[rs].zgs = 1;
A[ls].Wclear() , A[rs].Wclear();
B[ls].lazy1 = B[rs].lazy1 = B[rt].lazy1;
B[ls].lazy2 = B[ls].lazy3 = B[rs].lazy2 = B[rs].lazy3 = 0;
B[ls].man = B[rs].man = 1;
A[ls].aji = B[ls].aji = B[ls].lji = B[ls].rji = Wqp(B[rt].lazy1 , mid - l + 1);
A[rs].aji = B[rs].aji = B[rs].lji = B[rs].rji = Wqp(B[rt].lazy1 , r - mid);
B[ls].lv1 = B[ls].rv1 = B[ls].v1 = B[ls].v2 = B[ls].v3 = B[ls].v4 = (unsigned) B[ls].llen*B[ls].lji;
B[rs].lv1 = B[rs].rv1 = B[rs].v1 = B[rs].v2 = B[rs].v3 = B[rs].v4 = (unsigned) B[rs].llen*B[rs].lji;
B[rt].lazy1 = 0;
}
void Wpull(int rt , int l , int r)
{
B[rt].Wclear();
A[rt].llen = A[rt].rlen = r - l + 1;
// A[rt].lazy1=A[rt].lazy3=0;
A[rt].zgs = 1;
A[rt].lji = A[rt].rji = A[rt].aji;
A[rt].lv1 = A[rt].rv1 = A[rt].v1 = A[rt].v2 = A[rt].v3 = A[rt].v4 = (unsigned) A[rt].aji * (r - l + 1);
A[rt].man = 1;
}
void WpushdownA2(int rt , int l , int r)
{
Wpull(ls , l , mid) , Wpull(rs , mid + 1 , r);
A[ls].lazy2 = A[rs].lazy2 = 1;
A[rt].lazy2 = 0;
}
void WpushdownB2(int rt , int l , int r)
{
Wpull(ls , l , mid) , Wpull(rs , mid + 1 , r);
swap(A[ls] , B[ls]) , swap(A[rs] , B[rs]);
B[ls].lazy2 = B[rs].lazy2 = 1;
B[rt].lazy2 = 0;
}
void Wpushdown3(int rt)
{
swap(A[ls] , B[ls]) , swap(A[rs] , B[rs]);
A[ls].lazy3 = B[ls].lazy3 ^ 1,A[rs].lazy3 = B[rs].lazy3 ^ 1;
A[rt].lazy3 = 0;
}
void Wbuild(int rt , int l , int r)
{
if(l == r)
{
if(a[l] > 0)
A[rt].llen = A[rt].rlen = A[rt].zgs = 1 ,
A[rt].lji = A[rt].rji = a[l] , A[rt].man = 1 ,
A[rt].lv1 = A[rt].rv1 = A[rt].v1 = A[rt].v2 = A[rt].v3 = A[rt].v4 = a[l] ,
A[rt].aji = B[rt].aji = a[l] ,
B[rt].Wclear();
else
B[rt].llen = B[rt].rlen = B[rt].zgs = 1 ,
B[rt].lji = B[rt].rji = - a[l] , B[rt].man = 1 ,
B[rt].lv1 = B[rt].rv1 = B[rt].v1 = B[rt].v2 = B[rt].v3 = B[rt].v4 = - a[l] ,
A[rt].aji = B[rt].aji = - a[l] ,
A[rt].Wclear();
return;
}
Wbuild(ls , l , mid) , Wbuild(rs , mid + 1 , r);
WpushupA(rt);
WpushupB(rt);
}
void Wupd1(int rt , int l , int r , int x , int y , int k)
{
// return ;
if(x <= l && r <= y)
{
if(k > 0)
{
A[rt].llen = A[rt].rlen = r - l + 1 , A[rt].zgs = 1 , A[rt].man = 1;
A[rt].aji = B[rt].aji = A[rt].lji = A[rt].rji = Wqp(k , r - l + 1);
A[rt].lv1 = A[rt].rv1 = A[rt].v1 = A[rt].v2 = A[rt].v3 = A[rt].v4 = (unsigned) A[rt].llen*A[rt].lji;
A[rt].lazy1 = k;
A[rt].lazy2 = A[rt].lazy3 = 0;
B[rt].Wclear();
}
else
{
B[rt].llen = B[rt].rlen = r - l + 1 , B[rt].zgs = 1 , B[rt].man = 1;
A[rt].aji = B[rt].aji = B[rt].lji = B[rt].rji = Wqp( -k , r - l + 1);
B[rt].lv1 = B[rt].rv1 = B[rt].v1 = B[rt].v2 = B[rt].v3 = B[rt].v4 = (unsigned) B[rt].llen*B[rt].lji;
B[rt].lazy1 = -k;
B[rt].lazy2 = B[rt].lazy3 = 0;
A[rt].Wclear();
}
return;
}
if(A[rt].lazy1) /*cout<<"Wupd1PDA1 "<<l<<' '<<r<<endl,*/WpushdownA1(rt , l , r);
if(B[rt].lazy1) /*cout<<"Wupd1PDB1 "<<l<<' '<<r<<endl,*/WpushdownB1(rt , l , r);
if(A[rt].lazy2) /*cout<<"Wupd1PDA2 "<<l<<' '<<r<<endl,*/WpushdownA2(rt , l , r);
if(B[rt].lazy2) /*cout<<"Wupd1PDB2 "<<l<<' '<<r<<endl,*/WpushdownB2(rt , l , r);
if(A[rt].lazy3) Wpushdown3(rt);
if(x <= mid) Wupd1(ls , l , mid , x , y , k);
if(y > mid) Wupd1(rs , mid + 1 , r , x , y , k);
WpushupA(rt) , WpushupB(rt);
// if(l==1&&r==5) cout<<rt<<endl;
}
void Wupd2(int rt , int l , int r , int x , int y , int k)
{
// cout<<l<<' '<<r<<' '<<x<<' '<<y<<' '<<k<<endl;
if(A[rt].lazy1) /*cout<<"Wupd2PDA1 "<<l<<' '<<r<<endl,*/WpushdownA1(rt , l , r);
if(B[rt].lazy1) /*cout<<"Wupd2PDB1 "<<l<<' '<<r<<endl,*/WpushdownB1(rt , l , r);
if(x <= l && r <= y)
{
// if(A[rt].lazy1) WpushdownA1(rt,l,r),WpushupA(rt);
// if(B[rt].lazy1) WpushdownB1(rt,l,r),WpushupB(rt);
Wpull(rt , l , r);
if(k == -1)
{
swap(A[rt] , B[rt]);
B[rt].lazy2 = 1;
}
else
{
A[rt].lazy2 = 1;
}
return;
}
if(A[rt].lazy1) /*cout<<"Wupd2PDA1 "<<l<<' '<<r<<endl,*/WpushdownA1(rt , l , r);
if(B[rt].lazy1) /*cout<<"Wupd2PDB1 "<<l<<' '<<r<<endl,*/WpushdownB1(rt , l , r);
if(A[rt].lazy2) /*cout<<"Wupd2PDA2 "<<l<<' '<<r<<endl,*/WpushdownA2(rt , l , r);
if(B[rt].lazy2) /*cout<<"Wupd2PDB2 "<<l<<' '<<r<<endl,*/WpushdownB2(rt , l , r);
if(A[rt].lazy3) Wpushdown3(rt);
if(x <= mid) Wupd2(ls , l , mid , x , y , k);
if(y > mid) Wupd2(rs , mid + 1 , r , x , y , k);
WpushupA(rt) , WpushupB(rt);
}
void Wupd3(int rt , int l , int r , int x , int y)
{
if(x <= l && r <= y)
{
swap(A[rt] , B[rt]);
A[rt].lazy3 = B[rt].lazy3 ^ 1;
return;
}
// cout<<"!!!1 "<<A[rt].v1<<' '<<A[rt].v2<<' '<<A[rt].v3<<' '<<A[rt].v4<<endl;
if(A[rt].lazy1) WpushdownA1(rt , l , r);
if(B[rt].lazy1) WpushdownB1(rt , l , r);
if(A[rt].lazy2) WpushdownA2(rt , l , r);
if(B[rt].lazy2) WpushdownB2(rt , l , r);
if(A[rt].lazy3) Wpushdown3(rt);
if(x <= mid) Wupd3(ls , l , mid , x , y);
if(y > mid) Wupd3(rs , mid + 1 , r , x , y);
WpushupA(rt) , WpushupB(rt);
// cout<<"!!!2 "<<A[rt].v1<<' '<<A[rt].v2<<' '<<A[rt].v3<<' '<<A[rt].v4<<endl;
}
rmm Wmerge(rmm a,rmm b)
{
rmm c;
if(a.man && b.man) c.llen = c.rlen = a.llen + b.rlen ,
c.lji = c.rji = a.lji * b.rji , c.man = 1;
else if(!a.man && b.man) c.llen = a.llen , c.lji = a.lji ,
c.rlen = b.rlen + a.rlen , c.rji = b.rji * (a.rlen ? a.rji : 1) , c.man = 0;
else if(a.man && !b.man) c.rlen = b.rlen , c.rji = b.rji ,
c.llen = a.llen + b.llen , c.lji = a.lji * (b.llen ? b.lji : 1) , c.man = 0;
else c.llen = a.llen , c.rlen = b.rlen , c.lji = a.lji , c.rji = b.rji , c.man = 0;
if(a.rlen && b.llen) c.zgs = a.zgs + b.zgs - 1;
else c.zgs = a.zgs + b.zgs;
c.lv1 = c.llen * c.lji , c.rv1 = c.rlen * c.rji;
if(a.man && b.man)
{
c.v1=c.v2=c.v3=c.v4=a.rji*b.lji*(a.rlen+b.rlen);
}
else if(!b.llen || !a.rlen)
{// 没有合并块
c.v1 = a.v1 + b.v1;
c.v2 = a.v2 + b.v2 + b.v1 * a.zgs;
c.v3 = a.v3 + b.v3 + a.v1 * b.zgs;
c.v4 = a.v4 + b.v4 + b.zgs * a.v2 + a.zgs * b.v3;
}
else
{
c.v1 = a.v1 + b.v1 - a.rv1 - b.lv1 + a.rji * b.lji * (a.rlen + b.llen);
c.v2 = a.v2 + b.v2 - a.rv1 * a.zgs - b.lv1 + a.rji * b.lji * (a.rlen + b.llen) * a.zgs + (b.v1 - b.lv1) * (a.zgs - 1);
c.v3 = a.v3 + b.v3 - a.rv1 - b.lv1 * b.zgs + a.rji * b.lji * (a.rlen + b.llen) * b.zgs + (a.v1 - a.rv1) * (b.zgs - 1);
// cout<<"a:"<<a.v4<<' '<<a.rv1<<' '<<a.zgs<<' '<<a.v2<<' '<<a.rji<<' '<<a.rlen<<endl;
// cout<<"b:"<<b.v4<<' '<<b.lv1<<' '<<b.zgs<<' '<<b.v3<<' '<<b.lji<<' '<<b.llen<<endl;
c.v4 = a.v4 + b.v4 - a.rv1 * a.zgs - b.lv1 * b.zgs + (b.zgs - 1) * (a.v2 - a.rji * a.rlen * a.zgs) + (a.zgs - 1) * (b.v3 - b.lji * b.llen * b.zgs) + a.rji * b.lji * (a.rlen + b.llen) * (a.zgs) * (b.zgs);
}
// cout<<"c:"<<c.v1<<' '<<c.v2<<' '<<c.v3<<' '<<c.v4<<endl;
return c;
}
rmm Wq(int rt , int l , int r , int x , int y)
{
// cout << l << ' ' << r << ' ' << x << ' ' << y << endl;
if(x <= l && r <= y) return A[rt];
if(A[rt].lazy1) /*cout<<"WqPDA1 "<<l<<' '<<r<<endl,*/WpushdownA1(rt , l , r);
if(B[rt].lazy1) /*cout<<"WqPDB1 "<<l<<' '<<r<<endl,*/WpushdownB1(rt , l , r);
if(A[rt].lazy2) /*cout<<"WqPDA2 "<<l<<' '<<r<<endl,*/WpushdownA2(rt , l , r);
if(B[rt].lazy2) /*cout<<"WqPDB2 "<<l<<' '<<r<<endl,*/WpushdownB2(rt , l , r);
if(A[rt].lazy3) Wpushdown3(rt);
/*pushdown*/
unsigned res = 0;
int L = -1,R = -1;
rmm AA,BB;
if(x <= mid) AA = Wq(ls , l , mid , x , y) , L = 1;
if(y > mid) BB = Wq(rs , mid + 1 , r , x , y) , R = 1;
if(L == -1) return BB;
if(R == -1) return AA;
// cout<<x<<' '<<y<<endl;
return Wmerge(AA , BB);
}
unsigned Wqq(int rt , int l , int r , int x)
{
if(l == r) return A[rt].lji;
// if(A[rt].lazy1) WpushdownA1(rt , l , r);
// if(B[rt].lazy1) WpushdownB1(rt , l , r);
// if(A[rt].lazy2) WpushdownA2(rt , l , r);
// if(B[rt].lazy2) WpushdownB2(rt , l , r);
if(A[rt].lazy3) Wpushdown3(rt);
if(x<=mid) return Wqq(ls , l , mid , x);
else return Wqq(rs , mid + 1 , r , x);
}
unsigned Wqq1(int rt , int l , int r , int x)
{
if(l == r) return B[rt].lji;
if(A[rt].lazy1) WpushdownA1(rt , l , r);
if(B[rt].lazy1) WpushdownB1(rt , l , r);
if(A[rt].lazy2) WpushdownA2(rt , l , r);
if(B[rt].lazy2) WpushdownB2(rt , l , r);
if(A[rt].lazy3) Wpushdown3(rt);
if(x<=mid) return Wqq1(ls , l , mid , x);
else return Wqq1(rs , mid + 1 , r , x);
}
short main()
{
// freopen(".in" , "r" , stdin) , freopen(".out" , "w" , stdout);
freopen("a.in" , "r" , stdin) , freopen("a.out" , "w" , stdout);
n = qr , m = qr;
fo(i , 1 , n) a[i] = qr;
Wbuild(1 , 1 , n);
fo(i , 1 , m)
{
int op = qr , l = qr , r = qr , x;
if(op == 1)
{
x = qr;
Wupd1(1 , 1 , n , l , r , x);
/*直接赋值*/
}
else if(op == 2)
{
x = qr;
Wupd2(1 , 1 , n , l , r , x);
/*区间赋正负*/
}
else if(op == 3)
{
x = qr;
if(x == -1) Wupd3(1 , 1 , n , l , r);
/*区间不变、变相反数*/
}
else if(op == 4)
{
x = qr;
/*?*/
}
else
{
// cout<<l<<' '<<r<<endl;
// fo(j,l,r) Wqq(1,1,n,j);
rmm AAA=Wq(1 , 1 , n , l , r);
printf("%u\n" , AAA.v4);
// cout<<AAA.llen<<' '<<AAA.lji<<' '<<AAA.zgs<<' '<<AAA.rlen<<' '<<AAA.rji<<endl;
// cout<<Wq(1 , 1 , n , l , r)<<endl;
}
// cout<<"$%^&*()"<<endl;
// fo(i , 1 , n) Wqq(1 , 1 , n , i);
// // cout << Wqq(1, 1, n, 1, n);
// cout<<"%%%%%%\n";
}
return Ratio;
}
}
int main(){return Wisadel::main();}
没完结不撒花