# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
976843 |
2024-05-07T07:35:14 Z |
Isam |
XORanges (eJOI19_xoranges) |
C++17 |
|
74 ms |
8784 KB |
#include<bits/stdc++.h>
using namespace std;
constexpr int sz = 2e5 + 5;
int n, q, a[sz], tree[2][sz];
inline void update(int pos, int val, int bj){
while(pos <= n){
tree[bj][pos] ^= val;
pos += (pos & (-pos));
}
return;
}
inline int get_ans(int l, int r, int bj){
if(l ^ 1) return get_ans(1, r, bj) ^ get_ans(1, l - 1, bj);
int res(0);
while(r > 0){
res ^= tree[bj][r];
r -= (r & (-r));
}
return res;
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> q;
for(register int i = 1; i <= n; ++i){
cin >> a[i];
update(i, a[i], i & 1);
}
int type, l, r;
while(q--){
cin >> type >> l >> r;
if(type == 1){
update(l, a[l], l & 1);
a[l] = r;
update(l, a[l], l & 1);
}else{
if(~(r - l + 1) & 1){
cout << 0 << '\n';
}else{
cout << get_ans(l, r, l & 1) << '\n';
}
}
}
}
Compilation message
xoranges.cpp: In function 'int main()':
xoranges.cpp:43:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
43 | for(register int i = 1; i <= n; ++i){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2508 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2508 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
2 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2648 KB |
Output is correct |
11 |
Correct |
3 ms |
2652 KB |
Output is correct |
12 |
Correct |
2 ms |
2648 KB |
Output is correct |
13 |
Correct |
2 ms |
2652 KB |
Output is correct |
14 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
3952 KB |
Output is correct |
2 |
Correct |
69 ms |
8784 KB |
Output is correct |
3 |
Correct |
73 ms |
8704 KB |
Output is correct |
4 |
Correct |
66 ms |
8272 KB |
Output is correct |
5 |
Correct |
65 ms |
8436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2508 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
2 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2648 KB |
Output is correct |
11 |
Correct |
3 ms |
2652 KB |
Output is correct |
12 |
Correct |
2 ms |
2648 KB |
Output is correct |
13 |
Correct |
2 ms |
2652 KB |
Output is correct |
14 |
Correct |
2 ms |
2652 KB |
Output is correct |
15 |
Correct |
68 ms |
3952 KB |
Output is correct |
16 |
Correct |
69 ms |
8784 KB |
Output is correct |
17 |
Correct |
73 ms |
8704 KB |
Output is correct |
18 |
Correct |
66 ms |
8272 KB |
Output is correct |
19 |
Correct |
65 ms |
8436 KB |
Output is correct |
20 |
Correct |
69 ms |
8404 KB |
Output is correct |
21 |
Correct |
74 ms |
8636 KB |
Output is correct |
22 |
Correct |
69 ms |
8376 KB |
Output is correct |
23 |
Correct |
64 ms |
8272 KB |
Output is correct |
24 |
Correct |
64 ms |
8276 KB |
Output is correct |