只有最后一个点WA了QAQ
拍不出来错误啊
求dalao指教
#include <bits/stdc++.h>
#define int long long
#define root 1,1,n
#define nows now,nowl,nowr
#define lson now<<1,nowl,m
#define rson now<<1|1,m+1,nowr
using namespace std;
const int Maxn=10000100;
struct SegMent_Tree
{
int l,r;
int b;
bool chips;
}z[4*Maxn];
int a[Maxn];
inline int ls(int node) {return node<<1;}
inline int rs(int node) {return node<<1|1;}
inline SegMent_Tree operator+(const SegMent_Tree &l,const SegMent_Tree &r)
{
if(l.l==0&&l.r==0) return r;
if(r.l==0&&r.r==0) return l;
SegMent_Tree temp;
temp.l=l.l,temp.r=r.r,temp.b=0;
if(l.r<=r.l&&l.chips&&r.chips) temp.chips=1;
else temp.chips=0;
return temp;
}
void build(int now,int nowl,int nowr)
{
if(nowl==nowr)
{
z[now].b=0,z[now].chips=1,z[now].l=z[now].r=a[nowl];
return;
}
int m=(nowl+nowr)>>1;
build(lson),build(rson);
z[now].l=z[now].r=z[now].b=0;
z[now]=z[now]+z[ls(now)]+z[rs(now)];
}
void color(int now,int nowl,int nowr,int plus)
{
z[now].l+=plus,z[now].r+=plus;
z[now].b+=plus;
}
void push_down(int now,int nowl,int nowr)
{
int m=(nowl+nowr)>>1;
if(z[now].b)
{
color(lson,z[now].b);
color(rson,z[now].b);
z[now].b=0;
}
}
void update_plus(int l,int r,int now,int nowl,int nowr,int plus)
{
if(l<=nowl&&nowr<=r)
{
color(nows,plus);
return;
}
int m=(nowl+nowr)>>1;
push_down(nows);
if(l<=m) update_plus(l,r,lson,plus);
if(r>m) update_plus(l,r,rson,plus);
z[now]=z[ls(now)]+z[rs(now)];
}
SegMent_Tree query(int l,int r,int now,int nowl,int nowr)
{
if(l<=nowl&&nowr<=r)
{
return z[now];
}
int m=(nowl+nowr)>>1;
push_down(nows);
SegMent_Tree temp;temp.l=temp.r=0,temp.b=0;
if(l<=m) temp=temp+query(l,r,lson);
if(r>m) temp=temp+query(l,r,rson);
return temp;
}
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0' || ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0' && ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
int n,m,opt;
signed main()
{
n=read(),m=read();
for(int i=1;i<=n;i++) a[i]=read();
build(root);
for(int i=0,l,r,x;i<m;i++)
{
opt=read();l=read();r=read();
if(r==n+1) r=n;
if(opt==1) x=read(),update_plus(l,r,root,x);
else
{
if(query(l,r,root).chips) cout<<"Yes\n";
else cout<<"No\n";
}
}
}
评测记录:哼哼哼啊啊啊啊啊