# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
444657 | 2021-07-14T14:13:04 Z | drkarlicio2107 | XORanges (eJOI19_xoranges) | C++14 | 662 ms | 4780 KB |
#include <bits/stdc++.h> using namespace std; int fen_parni [200010]; int fen_neparni [200010]; int l [200010]; void add_parni (int a, int v){ for (a; a<200000; a+= a & -a) fen_parni[a]^=v; } int query_parni (int a){ int res=0; for (a; a>0; a-= a & -a) res^=fen_parni[a]; return res; } void add_neparni (int a, int v){ for (a; a<200000; a+= a & -a) fen_neparni[a]^=v; } int query_neparni (int a){ int res=0; for (a; a>0; a-= a & -a) res^=fen_neparni[a]; return res; } int main(){ int n,q; cin >> n >> q; for (int i=1; i<n+1; i++){ int a; cin >> a; if (i%2==0) add_parni (i, a); else add_neparni (i, a); l[i]=a; /* if (i%2==0) cout << query_parni (i) << endl; else cout << query_neparni (i) << endl; */ } for (int i=0; i<q; i++){ int x; cin >> x; if (x==1){ int a, b; cin >> a >> b; if (a%2==0){ add_parni (a, l[a]); add_parni (a, b); } else { add_neparni (a, l[a]); add_neparni (a, b); } l[a]=b; } else { int l, r; cin >> l >> r; if ((r-l+1)%2==0) cout << 0 << endl; else { if (l==1){ if (r%2==0) cout << query_parni (r) << endl; else cout << query_neparni (r) << endl; } else if (r%2==0 && (l-1)%2==1) cout << (query_parni (r)^query_neparni (l-1)) << endl; else if (r%2==0 && (l-1)%2==0) cout << (query_parni (r)^query_parni (l-1)) << endl; else if (r%2==1 && (l-1)%2==1) cout << (query_neparni (r)^query_neparni (l-1)) << endl; else if (r%2==1 && (l-1)%2==0) cout << (query_neparni (r)^query_parni (l-1)) << endl; } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 662 ms | 4780 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |