#include<iostream> #include<cstdio> #include<cctype> #include<algorithm> using namespace std; #define INF 2000000030 #define max(x,y) ((x)>(y)?(x):(y)) #define min(x,y) ((x)<(y)?(x):(y)) int n,m,op,x,y,l,r,k,tot,yes; int a[1200030]; int ssum[1200030],Max[1200030],Min[1200030],sum[1200030]; char buf[40000020]; int bufpos; inline void init(){ buf[fread(buf,1,40000020,stdin)]='\0'; bufpos=0; } inline int read(){ int p=0; for(;!isdigit(buf[bufpos]);bufpos++); for(;isdigit(buf[bufpos]);bufpos++) p=p*10+buf[bufpos]-'0'; return p; } inline void update(int cur){ Max[cur]=max(Max[cur<<1],Max[cur<<1|1]); Min[cur]=min(Min[cur<<1],Min[cur<<1|1]); sum[cur]=sum[cur<<1]+sum[cur<<1|1]; ssum[cur]=ssum[cur<<1]+ssum[cur<<1|1]; } void modify(int x,int y,int l,int r,int cur){ if (l==r){ Max[cur]=y; Min[cur]=y; sum[cur]=y; ssum[cur]=y*y; return; } int mid=(l+r)>>1; if (x<=mid) modify(x,y,l,mid,cur<<1); if (x>mid) modify(x,y,mid+1,r,cur<<1|1); update(cur); } void build(int l,int r,int cur){ if (l==r){ Max[cur]=a[l]; Min[cur]=a[l]; sum[cur]=a[l]; ssum[cur]=a[l]*a[l]; return; } int mid=(l+r)>>1; build(l,mid,cur<<1); build(mid+1,r,cur<<1|1); update(cur); } void q_all(int L,int R,int l,int r,int cur,int &MAX,int &MIN,int &SUM,int &SSUM){ if (L<=l && R>=r){ MAX=max(MAX,Max[cur]); MIN=min(MIN,Min[cur]); SUM+=sum[cur]; SSUM+=ssum[cur]; return; } int mid=(l+r)>>1; if (L<=mid) q_all(L,R,l,mid,cur<<1,MAX,MIN,SUM,SSUM); if (R>mid) q_all(L,R,mid+1,r,cur<<1|1,MAX,MIN,SUM,SSUM); } bool query(int L,int R,int k){ if (L==R) return 1; int MAX=0,MIN=INF,SUM=0,SSUM=0,N=r-l+1; q_all(L,R,1,n,1,MAX,MIN,SUM,SSUM); if (k==0) return MAX==MIN; return (MAX-MIN==k*(r-l)) && (SUM*2==(MIN+MAX)*N) && (SSUM*6==6*MIN*MIN*N+6*MIN*k*N*(N-1)+k*k*(N-1)*N*(N*2-1)); } int main(){ init(); n=read(); m=read(); for (int i=1;i<=n;i++) a[i]=read(); build(1,n,1); for (int i=1;i<=m;i++){ op=read(); if (op==1){ x=read()^yes; y=read()^yes; a[x]=y; modify(x,y,1,n,1); } if (op==2){ l=read()^yes; r=read()^yes; k=read()^yes; if (query(l,r,k)){ puts("Yes"); yes++; } else puts("No"); } } return 0; }
|