# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
929234 | 2024-02-18T04:03:42 Z | bambaa | XORanges (eJOI19_xoranges) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include <iostream> #include <set> #include <cmath> #include <iterator> #include <vector> #define ff first #define ss second #define mp make_pair #define ll long long using namespace std; int main() { int n, q; cin >> n >> q; int a[n]; for (int i = 0; i < n; i++){ cin >> a[i]; } if (n <= 5000 && q <= 5000){ for (int lol = 0; lol < q; lol++){ int x, y, z; cin >> x >> y >> z; if (x == 1) {a[y - 1] = z;} else { if (z - y % == 1) {cout << "0" << endl; continue;} int p = a[y - 1] for (int i = y + 1; i < z; i = i + 2){ p = (p ^ a[i]); } cout << p << endl; } } } else { int b[n]; b[0] = a[0]; b[1] = b[1]; for (int i = 2; i < n; i++){ b[i] = (b[i - 2] ^ a[i]); } for (int lol = 0; lol < q; lol++){ int x, y, z; cin >> x >> y >> z; if (x == 1) {a[y - 1] = z;} else { if (z - y % == 1) {cout << "0" << endl; continue;} int p = ((b[z - 1] ^ b[y - 1]) ^ a[y - 1]); cout << p << endl; } } } return 0; }