제출 #761163

#제출 시각아이디문제언어결과실행 시간메모리
761163LucaLucaMXORanges (eJOI19_xoranges)C++17
100 / 100
76 ms7924 KiB
#include <bits/stdc++.h> using namespace std; const int NMAX = 2e5; int a[NMAX + 5]; struct FenwickTree { int n; vector<int>aib; void build (int _n) { n = _n + 1; aib.resize(n, 0); } void update (int pos, int val) { for (; pos < n; pos += pos & -pos) aib[pos] ^= val; } int query (int pos) { int ret = 0; for (; pos > 0; pos -= pos & -pos) ret ^= aib[pos]; return ret; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; FenwickTree aib[2]; aib[0].build(n / 2 + 1); aib[1].build(n / 2 + 1); for (int i=2; i<=n+1; i++) { cin >> a[i]; aib[i & 1].update(i / 2, a[i]); } while (q--) { int op, x, y; cin >> op >> x >> y; x++; if (op == 1) { int v = (a[x] ^ y); aib[x & 1].update(x / 2, v); a[x] = y; } else { y++; int ans = 0; if (x % 2 != y % 2) { cout << "0\n"; continue; } if (x % 2 == 0) { x /= 2, y /= 2; cout << (aib[0].query(y) ^ aib[0].query(x - 1)) << '\n'; } else { x /= 2, y /= 2; cout << (aib[1].query(y) ^ aib[1].query(x - 1)) << '\n'; } } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

xoranges.cpp: In function 'int main()':
xoranges.cpp:61:17: warning: unused variable 'ans' [-Wunused-variable]
   61 |             int ans = 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...