-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathCLONEME.cpp
56 lines (49 loc) · 1019 Bytes
/
CLONEME.cpp
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
// Code wriiten by Monal
#include "bits/stdc++.h"
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int tc;
cin>>tc;
while (tc--) {
long int n,q;
cin>>n>>q;
vector < long int > arr(n);
for (int i = 0; i < n; ++i)
cin>>arr[i];
while (q--) {
long long int sum1 = 0, sum2 = 0;
long int a, b, c, d;
cin>>a>>b>>c>>d;
bool passer = true;
bool chance = true;
long int copyn = b - a + 1;
vector < long int > arr1(copyn);
vector <long int > arr2(copyn);
long int j = a - 1;
for (long int i = 0; i < copyn; ++i, ++j)
arr1[i] = arr[j];
sort(arr1.begin(), arr1.end());
j = c - 1;
for (long int i = 0; i < copyn; ++i, ++j)
arr2[i] = arr[j];
sort(arr2.begin(), arr2.end());
for (long int i = 0; i < copyn; ++i) {
if (arr1[i] != arr2[i]) {
if (chance)
chance = false;
else {
passer = false;
break;
}
}
}
if (passer)
cout<<"YES\n";
else
cout<<"NO\n";
}
}
return 0;
}