#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<stack> #include<queue> #include<deque> #include<vector> #include<algorithm> #include<iomanip> #include<cstdlib> #include<cctype> #include<cmath> #include<map> #include<set>
#define ll long long #define I inline #define N 300001
using namespace std;
ll n , m , a[N] , b[N];
map<int , int > M; set<int > S[N]; int cnt;
int opt , num , x , p , l , r , d;
namespace Segment_tree{ #define lson(x) x << 1 #define rson(x) x << 1 | 1
ll maxn[N << 2] , minn[N << 2] , Gcd[N << 2] , l[N << 2] , r[N << 2] , last[N << 2];
ll gcd(ll a , ll b){ return !b ? a : gcd(b , a % b); }
void pushup(int x){ minn[x] = min(minn[lson(x)] , minn[rson(x)]); maxn[x] = max(maxn[lson(x)] , maxn[rson(x)]); Gcd[x] = gcd(Gcd[lson(x)] , Gcd[rson(x)]); last[x] = max(last[lson(x)] , last[rson(x)]); return ; }
void build(int x , int ql , int qr){ l[x] = ql , r[x] = qr; if(ql == qr){ maxn[x] = minn[x] = a[ql]; Gcd[x] = b[ql]; last[x] = 0; return ; } int mid = (ql + qr) >> 1; build(lson(x) , ql , mid); build(rson(x) , mid + 1 , qr); pushup(x); }
void change(int k , int p , int x , int opt){ if(l[k] == r[k]){ if(opt == 0){ maxn[k] = minn[k] = x; } else if(opt == 1){ Gcd[k] = x; } else{ last[k] = x; } return ; } int mid = (l[k] + r[k]) >> 1; if(p <= mid){ change(lson(k) , p , x , opt); } else{ change(rson(k) , p , x , opt); } pushup(k); }
ll range_max(int x , int ql , int qr){ if(l[x] == ql && r[x] == qr){ return maxn[x]; } int mid = (l[x] + r[x]) >> 1; if(mid >= qr){ return range_max(lson(x) , ql , qr); } else if(ql > mid){ return range_max(rson(x) , ql , qr); } else{ return max(range_max(lson(x) , ql , mid) , range_max(rson(x) , mid + 1 , qr)); } }
ll range_min(int x , int ql , int qr){ if(l[x] == ql && r[x] == qr){ return minn[x]; } int mid = (l[x] + r[x]) >> 1; if(mid >= qr){ return range_min(lson(x) , ql , qr); } else if(ql > mid){ return range_min(rson(x) , ql , qr); } else{ return min(range_min(lson(x) , ql , mid) , range_min(rson(x) , mid + 1 , qr)); } }
ll range_gcd(int x , int ql , int qr){ if(l[x] == ql && r[x] == qr){ return Gcd[x]; } int mid = (l[x] + r[x]) >> 1; if(mid >= qr){ return range_gcd(lson(x) , ql , qr); } else if(ql > mid){ return range_gcd(rson(x) , ql , qr); } else{ return gcd(range_gcd(lson(x) , ql , mid) , range_gcd(rson(x) , mid + 1 , qr)); } }
ll range_last(int x , int ql , int qr){ if(l[x] == ql && r[x] == qr){ return last[x]; } int mid = (l[x] + r[x]) >> 1; if(mid >= qr){ return range_last(lson(x) , ql , qr); } else if(ql > mid){ return range_last(rson(x) , ql , qr); } else{ return max(range_last(lson(x) , ql , mid) , range_last(rson(x) , mid + 1 , qr)); } }
}
int main(){ ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m; for(int i = 1; i <= n; i ++){ cin >> a[i]; b[i] = abs(a[i] - a[i - 1]); if(M.find(a[i]) == M.end()){ M[a[i]] = ++ cnt; S[cnt].insert(0); } S[M[a[i]]].insert(i); } Segment_tree :: build(1 , 1 , n);
for(int i = 1; i <= m; i ++){ cin >> opt; if(opt == 1){ cin >> p >> x; p ^= num , x ^= num; a[p] = x; Segment_tree :: change(1 , p , x , 0); Segment_tree :: change(1 , p , abs(a[p] - a[p - 1]) , 1); if(p <= n){ Segment_tree :: change(1 , p + 1 , abs(a[p + 1] - a[p]) , 1); } }
else{ cin >> l >> r >> d; l ^= num , r ^= num , d ^= num; if(Segment_tree :: range_max(1 , l , r) - Segment_tree :: range_min(1 , l , r) == 1ll * d * (r - l) && (d == 0 || l == r || ((Segment_tree :: range_gcd(1 , l + 1 , r) % d == 0) && Segment_tree :: range_last(1 , l , r) < l))){ ++ num; puts("Yes"); } else{ puts("No"); } } } return 0; }
|