# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
220350 | 2020-04-07T18:10:14 Z | Matteo_Verz | XORanges (eJOI19_xoranges) | C++11 | 149 ms | 8788 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 8 ms | 512 KB | Output is correct |
12 | Correct | 8 ms | 512 KB | Output is correct |
13 | Correct | 10 ms | 512 KB | Output is correct |
14 | Correct | 8 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 140 ms | 3832 KB | Output is correct |
2 | Correct | 142 ms | 8696 KB | Output is correct |
3 | Correct | 149 ms | 8788 KB | Output is correct |
4 | Correct | 132 ms | 8440 KB | Output is correct |
5 | Correct | 132 ms | 8440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 8 ms | 512 KB | Output is correct |
12 | Correct | 8 ms | 512 KB | Output is correct |
13 | Correct | 10 ms | 512 KB | Output is correct |
14 | Correct | 8 ms | 512 KB | Output is correct |
15 | Correct | 140 ms | 3832 KB | Output is correct |
16 | Correct | 142 ms | 8696 KB | Output is correct |
17 | Correct | 149 ms | 8788 KB | Output is correct |
18 | Correct | 132 ms | 8440 KB | Output is correct |
19 | Correct | 132 ms | 8440 KB | Output is correct |
20 | Correct | 145 ms | 8440 KB | Output is correct |
21 | Correct | 147 ms | 8532 KB | Output is correct |
22 | Correct | 147 ms | 8440 KB | Output is correct |
23 | Correct | 139 ms | 8312 KB | Output is correct |
24 | Correct | 139 ms | 8568 KB | Output is correct |