# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
929273 |
2024-02-18T04:29:10 Z |
hngr |
XORanges (eJOI19_xoranges) |
C++17 |
|
459 ms |
9612 KB |
#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#define int long long
const int maxn = 2e5+7;
using namespace std;
const int N=2e5+5;
int t[2][2*N]{0};
int a[N]{0};
int qr(int i,int l,int r,int sz,int res=0){
for(l += sz, r += sz; l < r; l >>= 1, r >>= 1){
if(l&1) res ^= t[i][l++];
if(r&1) res ^= t[i][--r];
}return res;
}
void upd(int i, int id, int amt, int sz){
for(id >>= 1; id; id >>= 1) t[i][id] = t[i][2*id]^t[i][2*id+1];
}
int32_t main(){
int n, q; cin >> n >> q;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i += 2) t[0][i+n] = a[i];
for(int i = 1; i < n; i += 2) t[1][i+n] = a[i];
for(int i = n-1; i > 0; i--) t[0][i] = t[0][2*i]^t[0][2*i+1], t[1][i]=t[1][2*i]^t[1][2*i+1];
while(q--){
int gh; cin >> gh;
if(gh == 1){
int i, j; cin >> i >> j;
if((i - 1)&1) upd(1, i-1, j, n);
else upd(0, i-1, j, n);
}
else {
int l, r; cin >> l >> r;
if((r-l+1)%2 == 0) cout << 0 <<'\n';
else cout << qr ((l-1)%2, l-1, r, n) <<'\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4440 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
459 ms |
9404 KB |
Output is correct |
2 |
Correct |
434 ms |
9344 KB |
Output is correct |
3 |
Correct |
418 ms |
9612 KB |
Output is correct |
4 |
Correct |
410 ms |
9316 KB |
Output is correct |
5 |
Correct |
436 ms |
9412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |