Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
32974 | LYLAKIOI | 【S】T3 | C++ | 通过 | 100 | 341 MS | 25616 KB | 2740 | 2024-10-02 16:33:35 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define p_b push_back #define m_p make_pair using namespace std; typedef long long ll; const int maxn=2e5+10; const ll inf=1e14; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n,a[maxn]; struct nd { ll s0,s1,mn0,mn1; int len; void ins(int c){ int f1=len>>1,f2=len-f1; s0+=f1*1ll*c,s1+=f2*1ll*c,mn1+=c; } }; nd operator+(nd a,nd b){ nd res;res.len=a.len+b.len; if(a.len&1){ res.mn0=min(a.mn0,b.mn1+a.s0-a.s1); res.mn1=min(a.mn1,b.mn0+a.s1-a.s0); res.s0=a.s0+b.s1; res.s1=a.s1+b.s0; }else { res.mn0=min(a.mn0,b.mn0+a.s0-a.s1); res.mn1=min(a.mn1,b.mn1+a.s1-a.s0); res.s0=a.s0+b.s0; res.s1=a.s1+b.s1; }return res; } struct SegTree { struct node { nd sm;int lz; }d[maxn<<2]; #define ls(p) (p<<1) #define rs(p) (p<<1|1) #define sm(p) d[p].sm #define lz(p) d[p].lz void pu(int p){sm(p)=sm(ls(p))+sm(rs(p));} void cl(int p,int x){sm(p).ins(x),lz(p)+=x;} void pd(int p){cl(ls(p),lz(p)),cl(rs(p),lz(p));lz(p)=0;} void bd(int l,int r,int p){ if(l==r){ sm(p)=(nd){0,a[l],inf,a[l],1};return; }int mid=l+r>>1; bd(l,mid,ls(p)),bd(mid+1,r,rs(p));pu(p); } void modify(int l,int r,int s,int t,int p,int x){ if(l<=s&&t<=r){cl(p,x);return;}pd(p); int mid=s+t>>1; if(l<=mid)modify(l,r,s,mid,ls(p),x);if(r>=mid+1)modify(l,r,mid+1,t,rs(p),x);pu(p); }nd qry(int l,int r,int s,int t,int p){ if(l<=s&&t<=r)return sm(p);pd(p); int mid=s+t>>1; if(r<=mid)return qry(l,r,s,mid,ls(p)); if(l>=mid+1)return qry(l,r,mid+1,t,rs(p)); return qry(l,r,s,mid,ls(p))+qry(l,r,mid+1,t,rs(p)); } }T; void slv(){ n=read();up(i,1,n)a[i]=read(),--a[i]; T.bd(1,n,1);int q=read(); while(q--){ int op=read(),l=read(),r=read(); if(op==1){ int x=read();T.modify(l,r,1,n,1,x); }else { nd w=T.qry(l,r,1,n,1); //cout<<"! "<<w.mn0<<" "<<w.mn1<<" "<<w.s0<<" "<<w.s1<<"\n"; if(w.s0==w.s1&&w.mn0>=0&&w.mn1>=0)printf("Yes\n"); else printf("No\n"); } } }int main(){ //freopen("apple.in","r",stdin); //freopen("apple.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }