#include<bits/stdc++.h>
using namespace std;
#define pass true
int main () {
int n, q;
cin >> n >> q;
vector<int> prefix(n+1, 0);
vector<int> prefixOdd(n+1, 0);
vector<int> v(n, 0);
bool check = false;
for(int i = 0;i<n;i++) {
int p;
cin >> p;
prefix[i+1] = prefix[i] ^ p;
if(i%2 == 0) {
prefixOdd[i+1] = prefixOdd[i] ^ p;
}
else {
prefixOdd[i+1] = prefixOdd[i];
}
v[i] = p;
}
while(q--) {
int k;
cin >> k;
if(k == 1) {
check = true;
int i, j;
cin >> i >> j;
v[i-1] = j;
}
else {
int l, u;
cin >> l >> u;
if(!check) {
if((u - l)%2 == 0) {
if(l%2 == 1) {
int ans = prefixOdd[u] ^ prefixOdd[l-1];
cout<<(ans)<<endl;
}
else {
int ans = prefix[u] ^ prefixOdd[u] ^ prefix[l-1] ^ prefixOdd[l-1];
cout<<ans<<endl;
}
}
else {
cout<<0<<endl;
}
}
else {
int s = 0;
l--;
u = min(u, n);
for(int i = l;i<u;i++) {
if(((i - l + 1)*(u - i))%2)s^=v[i];
}
cout<<s<<endl;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
16 ms |
356 KB |
Output is correct |
12 |
Correct |
16 ms |
332 KB |
Output is correct |
13 |
Correct |
39 ms |
356 KB |
Output is correct |
14 |
Correct |
40 ms |
356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
643 ms |
3844 KB |
Output is correct |
2 |
Correct |
615 ms |
3788 KB |
Output is correct |
3 |
Correct |
594 ms |
3832 KB |
Output is correct |
4 |
Correct |
586 ms |
3940 KB |
Output is correct |
5 |
Correct |
591 ms |
3972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
16 ms |
356 KB |
Output is correct |
12 |
Correct |
16 ms |
332 KB |
Output is correct |
13 |
Correct |
39 ms |
356 KB |
Output is correct |
14 |
Correct |
40 ms |
356 KB |
Output is correct |
15 |
Correct |
643 ms |
3844 KB |
Output is correct |
16 |
Correct |
615 ms |
3788 KB |
Output is correct |
17 |
Correct |
594 ms |
3832 KB |
Output is correct |
18 |
Correct |
586 ms |
3940 KB |
Output is correct |
19 |
Correct |
591 ms |
3972 KB |
Output is correct |
20 |
Execution timed out |
1089 ms |
2840 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |