Skip to content

Commit cacf1cb

Browse files
authored
Merge pull request #299 from himadeepthi1/c3
This problem involves pre-computation
2 parents 0a86e94 + d6f8a0e commit cacf1cb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Coding/C++/Pre-computation.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)