1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
| #include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<map> #define ll int using namespace std;
const ll N=3e5;
ll n,m,op,x,y,tot,top,cnt,k;
ll a[N+5],pre[N+5],st[N+5],d[N+5];
set<ll> s[N+5];
map<ll,ll> ss,mp;
struct sgt{ ll l,r,ma,mi,mpre,g; #define l(x) tree[x].l #define r(x) tree[x].r #define ma(x) tree[x].ma #define mi(x) tree[x].mi #define mpre(x) tree[x].mpre #define g(x) tree[x].g }tree[N*4+5];
inline ll gcd(ll a,ll b) { if(b==0) return a; return gcd(b,a%b); }
inline void build(ll p,ll l,ll r) { l(p)=l;r(p)=r; if(l==r) { ma(p)=a[l];mi(p)=a[l];mpre(p)=pre[l];g(p)=d[l]; return; } ll mid=(l+r)>>1; build(p<<1,l,mid);build(p<<1|1,mid+1,r); ma(p)=max(ma(p<<1),ma(p<<1|1)); mi(p)=min(mi(p<<1),mi(p<<1|1)); mpre(p)=max(mpre(p<<1),mpre(p<<1|1)); g(p)=gcd(g(p<<1),g(p<<1|1)); }
inline void modifypre(ll p,ll x,ll y) { if(l(p)==r(p)) { mpre(p)=y;return; } ll mid=(l(p)+r(p))>>1; if(x<=mid) modifypre(p<<1,x,y); if(x>mid) modifypre(p<<1|1,x,y); mpre(p)=max(mpre(p<<1),mpre(p<<1|1)); }
inline void modifyval(ll p,ll x,ll y) { if(l(p)==r(p)) { ma(p)=y;mi(p)=y;return; } ll mid=(l(p)+r(p))>>1; if(x<=mid) modifyval(p<<1,x,y); if(x>mid) modifyval(p<<1|1,x,y); ma(p)=max(ma(p<<1),ma(p<<1|1)); mi(p)=min(mi(p<<1),mi(p<<1|1)); }
inline void modifyg(ll p,ll x,ll y) { if(l(p)==r(p)) { g(p)=y;return; } ll mid=(l(p)+r(p))>>1; if(x<=mid) modifyg(p<<1,x,y); if(x>mid) modifyg(p<<1|1,x,y); g(p)=gcd(g(p<<1),g(p<<1|1)); }
inline sgt get(ll p,ll l,ll r) { if(l(p)>=l&&r(p)<=r) return tree[p]; ll mid=(l(p)+r(p))>>1; if(l>mid) return get(p<<1|1,l,r); if(r<=mid) return get(p<<1,l,r); sgt L=get(p<<1,l,r),R=get(p<<1|1,l,r),res; res.ma=max(L.ma,R.ma); res.mi=min(L.mi,R.mi); res.mpre=max(L.mpre,R.mpre); res.g=gcd(L.g,R.g); return res; }
inline ll abs(ll x) { if(x<0) return -x;return x; }
inline ll read() { ll ret=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9') {if(ch=='-') f=-f;ch=getchar();} while(ch>='0'&&ch<='9') {ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();} return ret*f; }
inline void write(ll x) { static char buf[22];static ll len=-1; if(x>=0) { do{buf[++len]=x%10+48;x/=10;}while(x); } else { do{buf[++len]=-(x%10)+48;x/=10;}while(x); } while(len>=0) putchar(buf[len--]); }
int main() {
n=read();m=read();
for(ll i=1;i<=n;i++) { a[i]=read();d[i]=abs(a[i]-a[i-1]); if(ss.find(a[i])==ss.end()) pre[i]=0; else pre[i]=ss[a[i]]; ss[a[i]]=i; if(mp.find(a[i])==mp.end()) mp[a[i]]=++tot; s[mp[a[i]]].insert(i); }
build(1,1,n);
while(m--) { op=read();x=read();y=read(); x^=cnt;y^=cnt; if(op==1) { ll temp1=mp[a[x]],temp2=0,tmppre=0,pos=0; if(mp.find(y)!=mp.end()) temp2=mp[y]; else temp2=mp[y]=++tot; set<ll>::iterator it1,it2,it0; it0=it1=it2=s[temp1].find(x); if(it1!=s[temp1].begin()) tmppre=*--it1; if(++it2!=s[temp1].end()) pos=*it2; if(pos>0) modifypre(1,pos,tmppre); s[temp1].erase(it0); s[temp2].insert(x); it1=it2=s[temp2].find(x); if(it1==s[temp2].begin()) modifypre(1,x,0); else modifypre(1,x,*--it1); if(++it2!=s[temp2].end()) modifypre(1,*it2,x); modifyg(1,x,abs(y-a[x-1])); if(x+1<=n) modifyg(1,x+1,abs(a[x+1]-y)); modifyval(1,x,y);a[x]=y; d[x]=abs(y-a[x-1]); if(x+1<=n) d[x+1]=abs(a[x+1]-y); } if(op==2) { k=read();k^=cnt; sgt tmp=get(1,x,y); if(y-x==0) { printf("Yes\n");cnt++;continue; } sgt tmpp=get(1,x+1,y); if(k==0&&tmp.ma==tmp.mi) { printf("Yes\n");cnt++; } else if(tmp.mpre<x&&tmpp.g==k&&tmp.ma-tmp.mi==k*(y-x)) { printf("Yes\n");cnt++; } else printf("No\n"); } }
return 0; }
|