-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1807d.cpp
More file actions
45 lines (33 loc) · 893 Bytes
/
Copy path1807d.cpp
File metadata and controls
45 lines (33 loc) · 893 Bytes
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
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
int main() {
fastio;
int t;
cin >> t;
while (t--) {
long n,q;
cin >> n >> q;
vector<long> a(n+1),prefix(n+1);
for(int i = 1;i <= n;i++){
cin >> a[i];
a[i] %= 2;
prefix[i] = prefix[i-1] + a[i];
}
int total_parity = prefix[n] % 2;
while(q--){
long l,r,k;
cin >> l >> r >> k;
int len = r - l + 1;
int old_parity = (prefix[r] - prefix[l-1])%2;
int new_parity = (len % 2) * (k % 2);
int final_parity = total_parity ^ old_parity ^ new_parity;
if(final_parity){
cout << "YES\n";
}else{
cout << "NO\n";
}
}
}
return 0;
}