-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1807_D_Odd_Queries.cpp
54 lines (50 loc) · 1.31 KB
/
1807_D_Odd_Queries.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
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n, m;
cin >> n >> m;
vector<int> arr(n);
int oddCount = 0;
int evenCount = 0;
for(int i=0; i<n; i++){
int temp;
cin >> temp;
if(temp %2 == 0){
arr[i] = 0;
evenCount++;
}
else{
arr[i] = 1;
oddCount++;
}
}
// cout << oddCount << " " << evenCount << endl;
for(int i = 0; i<m; i++){
int a, b, k;
cin >> a >> b >> k;
int toddCount = oddCount;
int tevenCount = evenCount;
int check = 1;
if(k%2 == 0) check = 0;
for(int j=a-1; j<b; j++){
if(arr[j] != check){
if(check == 1){
toddCount++;
tevenCount--;
}
else{
toddCount--;
tevenCount++;
}
}
}
if(toddCount%2 == 1) cout << "YES" << endl;
else cout << "NO" << endl;
// cout << toddCount << " " << tevenCount << endl;
}
}
return 0;
}