We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0a86e94 + d6f8a0e commit cacf1cbCopy full SHA for cacf1cb
Coding/C++/Pre-computation.cpp
@@ -0,0 +1,43 @@
1
+// https://codeforces.com/problemset/problem/1807/D
2
+
3
+#include <bits/stdc++.h>
4
5
+using namespace std;
6
7
+int main(){
8
+ int t;
9
+ cin>>t;
10
+ while(t--){
11
+ int n,q;
12
+ cin>>n>>q;
13
+ long long int a[n];
14
+ long long int sum=0;
15
+ for(int i=0;i<n;i++){
16
+ cin>>a[i];
17
18
+ }
19
+ long long int pf[n+1];
20
+ pf[0]=0;
21
+ for(int i=1;i<=n;i++){
22
+ pf[i]=a[i-1]+pf[i-1];
23
24
25
+ for(int i=0;i<q;i++){
26
+ long long int l,r,k;
27
+ cin>>l>>r>>k;
28
+ long long int e=pf[n]-(pf[r]-pf[l-1])+k*(r-l+1);
29
30
31
+ if(e%2!=0){
32
+ cout<<"YES"<<endl;
33
+ }else{
34
+ cout<<"NO"<<endl;
35
36
37
38
39
40
41
42
+ return 0;
43
+}
0 commit comments