제출 #779328

#제출 시각아이디문제언어결과실행 시간메모리
779328vjudge1XORanges (eJOI19_xoranges)C++17
100 / 100
317 ms8124 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int n, q, opt, x, y, tree[2][200005], a[200005]; // tree[0 / 1] 表示 l 为[偶 / 奇]数时的树状数组 inline int lowbit(int x) { return x & (-x); } inline void add(int x, int y, int f) { while(x <= n) tree[f][x] ^= y, x += lowbit(x); } inline void build() { for(int i = 1; i <= n; i++) { cin >> a[i]; add(i, a[i], i % 2); } } inline int query(int x, int f) { int sum = 0; while(x) sum ^= tree[f][x], x -= lowbit(x); return sum; } signed main() { ios :: sync_with_stdio(false); cin >> n >> q; build(); while(q--) { cin >> opt >> x >> y; if(opt == 1) { add(x, a[x] ^ y, x % 2); a[x] = y; } else if((x + y) & 1) cout << "0\n"; else cout << (query(y, x % 2) ^ query(x - 1, x % 2)) << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...