# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
220346 | 2020-04-07T18:05:06 Z | Matteo_Verz | XORanges (eJOI19_xoranges) | C++11 | 142 ms | 8692 KB |
/* `-/oo+/- `` .oyhhhhhhyo.`od +hhhhyyoooos. h/ +hhyso++oosy- /s .yoooossyyo:``-y` ..----.` ``.-/+:.` `````..-::/. `..```.-::///` `-.....--::::/: `.......--::////: `...`....---:::://: `......``..--:::::///:` `---.......--:::::////+/` ----------::::::/::///++: ----:---:::::///////////:` .----::::::////////////:-` `----::::::::::/::::::::- `.-----:::::::::::::::- ...----:::::::::/:-` `.---::/+osss+:` ``.:://///-. */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <cmath> using namespace std; const int INF = 2e9; const int N = 2e5; int n, q; int v[5 + N]; class AIB{ private: int a[5 + N]; int lsb(int i){ return (i & (-i)); } public: void Build(int pos, int val){ for(int i = pos; i <= n; i += lsb(i)) a[i] = a[i] ^ val; } void Update(int pos, int val){ for(int i = pos; i <= n; i += lsb(i)) a[i] = a[i] ^ v[pos] ^ val; v[pos] = val; } int Query(int pos){ int s(0); for(int i = pos; i >= 1; i -= lsb(i)) s ^= a[i]; return s; } }; AIB FenwOdd, FenwEven; int main() { #ifdef CP freopen("xoranges.in", "r", stdin); freopen("xoranges.out", "w", stdout); #endif // CP scanf("%d%d", &n, &q); for(int i = 1; i <= n; i++){ scanf("%d", &v[i]); if(i & 1) FenwOdd.Build(i, v[i]); else FenwEven.Build(i, v[i]); } while(q--){ int t, x, y; scanf("%d%d%d", &t, &x, &y); if(t == 1){ if(x & 1) FenwOdd.Update(x, y); else FenwEven.Update(x, y); } else{ if((x - y + 1) & 1){ if(y & 1) printf("%d\n", FenwOdd.Query(y) - FenwOdd.Query(x - 2)); else printf("%d\n", FenwEven.Query(y) - FenwEven.Query(x - 2)); } else printf("0\n"); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 142 ms | 8692 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |