For this Question: You are given an array of size N. You will now be asked Q queries. In each query, you will be given two pairs of integers (A, B) and (C, D). To answer this query, you must take all values in the subarray [A, B] and sort them. Similarly, take all values in the subarray [C, D] and sort them. You need to print "Yes" if these two subarrays after sorting differ in atmost one position, otherwise print "No".The first line contains a single integer T – the number of test cases.
The first line of each test case contains two space-separated integers, N and Q.
The second line contains N space-separated integers A<sub>1</sub>, A<sub>2</sub> ... A<sub>N</sub>.
Then Q lines follow, each line containing four space-separated integers A, B, C and D.

<b> Constraints: </b>
1 ≤ T ≤ 10
1 ≤ N, Q ≤ 10<sup>5</sup>
1 ≤ A<sub>i</sub> ≤ 10<sup>5</sup>
B - A = D - COutput Q lines for each test case, each line containing either "Yes" or "No" denoting the answer to that query. Note that the <b>output is case-sensitive</b>.Sample Input 1:
3
3 3
1 2 3
1 2 2 3
1 3 1 3
1 1 3 3
6 3
1 2 3 1 2 3
1 3 4 6
1 4 2 5
1 5 2 6
3 3
1 1 1
1 2 2 3
1 1 2 2
1 3 1 3

Sample Output 1:
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes, I have written this Solution Code: #include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <chrono>
#include <random>
#include <bits/stdc++.h>
using namespace std;
 
#define ri register int
#define ll long long
 
//#define Neutral Shimokitazawa
 
#define Tp template<class T>
#ifdef Neutral
    const int End=1e6;
    char buf[End],*p1=buf,*p2=buf;
    #define g() (p1==p2&&(p2=(p1=buf)+fread(buf,1,End,stdin),p1==p2)?EOF:*p1++)
#else
    #define g() getchar()
#endif
#define pc(x) putchar(x)
#define isd(x) (x>=48&&x<=57)
namespace SlowIO{
    Tp inline void rd(T &x) {
        x=0; char i=g(); bool f=1;
        while(!isd(i)) f&=(i!='-'),i=g();
        while(isd(i)) x=(x<<3)+(x<<1)+(i^48),i=g();
        x*=((f<<1)-1);
    }
    const int OUT=1e6;
    static char outp[OUT]; int out;
    Tp inline void op(T x){
        out=0; x<0&&(x=-x,pc('-'));
        if(!x){ pc(48); return; }
        while(x) outp[++out]=x%10+48,x/=10;
        while(out) pc(outp[out--]);
    }
    Tp inline void writeln(T x){ op(x);pc('\n'); }
    Tp inline void writesp(T x){ op(x); pc(' '); }
    Tp inline void write(T x,char c=0){ op(x); c&&pc(c); }
}; using namespace SlowIO;
 
#define Seed chrono::steady_clock::now().time_since_epoch().count()
mt19937 rnd(Seed);
const int mod=19260817; //随机后的hash值区间[1,19260817] 
#define pii pair<int,int>
#define rp register pii
#define fir(x) x.first
#define sec(x) x.second
 
#define N 100001
int n,q,a[N];
int fash[N]; //fash[i]:值i对应的hash 由于hash和STL冲了所以以后都用fash（ 
struct __tree{
	struct seg{
		int lc,rc;
		ll val; int cnt;
	}tr[N*80]; int tot;
	#define lef(u) tr[u].lc
	#define rig(u) tr[u].rc
	#define Val(u) tr[u].val
	#define Cnt(u) tr[u].cnt
	inline void change(int &u,int lst,int l,int r,int x){
		tr[u=++tot]=tr[lst];
		Val(u)+=fash[x],++Cnt(u);
		if(l==r) return; ri mid=l+r>>1;
		if(x<=mid) change(lef(u),lef(lst),l,mid,x);
		else change(rig(u),rig(lst),mid+1,r,x);
	}
	inline pii qfirst(int u,int lst1,int v,int lst2,int l,int r){
		if(l==r) return {Cnt(u)-Cnt(lst1)-(Cnt(v)-Cnt(lst2)),l}; //由于不一定就是一个有而另一个无，可能是数量不同，所以需要记录数量差 
		ri mid=l+r>>1; bool t=Val(lef(u))-Val(lef(lst1))==Val(lef(v))-Val(lef(lst2));
		if(t) return qfirst(rig(u),rig(lst1),rig(v),rig(lst2),mid+1,r);
		else return qfirst(lef(u),lef(lst1),lef(v),lef(lst2),l,mid);
	} //直接在主席树上二分少只log 
	inline pii qlast(int u,int lst1,int v,int lst2,int l,int r){
		if(l==r) return {Cnt(u)-Cnt(lst1)-(Cnt(v)-Cnt(lst2)),l};
		ri mid=l+r>>1; bool t=Val(rig(u))-Val(rig(lst1))==Val(rig(v))-Val(rig(lst2));
		if(t) return qlast(lef(u),lef(lst1),lef(v),lef(lst2),l,mid);
		else return qlast(rig(u),rig(lst1),rig(v),rig(lst2),mid+1,r);
	} //first:最小的不相同数 last:最大的不相同数 
	inline int quecnt(int u,int lst,int l,int r,int L,int R){
		if(l>=L&&r<=R) return Cnt(u)-Cnt(lst);
		ri mid=l+r>>1,ret=0;
		if(L<=mid) ret=quecnt(lef(u),lef(lst),l,mid,L,R);
		if(R>mid) ret+=quecnt(rig(u),rig(lst),mid+1,r,L,R);
		return ret;
	}
	inline ll queval(int u,int lst,int l,int r,int L,int R){
		if(l>=L&&r<=R) return Val(u)-Val(lst);
		ri mid=l+r>>1; ll ret=0;
		if(L<=mid) ret=queval(lef(u),lef(lst),l,mid,L,R);
		if(R>mid) ret+=queval(rig(u),rig(lst),mid+1,r,L,R);
		return ret;
	}
}tr; int root[N];
const int lim=1e5;
inline bool query(int a,int b,int c,int d){
	if(tr.queval(root[b],root[a-1],1,lim,1,lim)
	==tr.queval(root[d],root[c-1],1,lim,1,lim)) return true; //哈希值相同 
	rp l=tr.qfirst(root[b],root[a-1],root[d],root[c-1],1,lim),
	r=tr.qlast(root[b],root[a-1],root[d],root[c-1],1,lim); 
	//if(sec(l)==sec(r)) return true; //上下界相同 这里不返回则下面上下界都不同 
	if(fir(l)*fir(r)>0) return false; //两个区间内都是同一棵树更多
	if(abs(fir(l))>=2||abs(fir(r))>=2) return false; //有任意一个边界存在一棵树比另一棵树多(>=2)个 
	return tr.quecnt(root[b],root[a-1],1,lim,sec(l)+1,sec(r)-1)==0&&
	tr.quecnt(root[d],root[c-1],1,lim,sec(l)+1,sec(r)-1)==0; //在上下界中间不存在其他数 
}
inline void Episode(){
	//play an episode for queries!
	if(!n) return;
	tr.tot=0,fill(fash+1,fash+lim+1,0);
}
#define readf(name) freopen(name".in","r",stdin)
#define writf(name) freopen(name".out","w",stdout)
 
int main()
{
	//readf("input3"),writf("mine");
	int T; rd(T);
	while(T--){
		tr.tot=0; //Episode();
		rd(n),rd(q);
		for(ri i=1;i<=n;++i){
			rd(a[i]);
			if(!fash[a[i]])
				fash[a[i]]=rnd()%mod+1;
			tr.change(root[i],root[i-1],1,lim,a[i]);
		} while(q--){
			int a,b,c,d;
			rd(a),rd(b),rd(c),rd(d);
			assert(d -c == b - a);
			if(a==c&&b==d){puts("Yes"); continue;}
			puts(query(a,b,c,d)?"Yes":"No");
		}
	}
	return 0;
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?