Submission #466177

#TimeUsernameProblemLanguageResultExecution timeMemory
466177BarayXORanges (eJOI19_xoranges)C++17
0 / 100
655 ms3936 KiB
#include <iostream> #include <cmath> #include <vector> #include <set> #include <map> using namespace std; #define ll long long #define MOD 1000000007 int T = 1, n, q, oper, a, b, sum, temp; vector<int> arr, odds; int seg[800000]; void init(int cur, int l, int r) { if (l == r) { seg[cur] = odds[l]; return; } init(cur * 2, l, (l + r) / 2); init(cur * 2 + 1, (l + r) / 2 + 1, r); seg[cur] = seg[cur * 2] ^ seg[cur * 2 + 1]; } int find(int cur, int l, int r, int tl, int tr) { if (l > tr || r < tl) { return 0; } if (l >= tl && r <= tr) { return seg[cur]; } int a1 = find(cur * 2, l, (r + l) / 2, tl, tr); int a2 = find(cur * 2 + 1, (l + r) / 2 + 1, r, tl, tr); return a1 ^ a2; } void change(int cur, int l, int r, int target, int val) { if (l > target || r < target) { return; } if (l == r && l == target) { seg[cur] = val; return; } change(cur * 2, l, (l + r) / 2, target, val); change(cur * 2 + 1, (l + r) / 2 + 1, r, target, val); seg[cur] = seg[cur * 2] ^ seg[cur * 2 + 1]; } void solve() { cin >> n >> q; //arr.push_back(-1); odds.push_back(-1); for (int i = 0; i < n; i++) { cin >> temp; arr.push_back(temp); if (!(i % 2)) { odds.push_back(temp); } } init(1, 1, odds.size()); for (int i = 0; i < q; i++) { cin >> oper >> a >> b; if (oper == 1) { if (a % 2 == 0) { continue; } change(1, 1, odds.size(), a / 2 + 1, b); } else { if ((a - b + 1) % 2 == 0) { cout << "0\n"; continue; } cout << find(1, 1, odds.size(), a / 2 + 1, b / 2 + 1) << "\n"; } } } int main() { //cin >> T; while (T--) { solve(); } }
#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...