# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
681381 | 2023-01-12T21:50:25 Z | USER | XOR Sum (info1cup17_xorsum) | C++14 | 1078 ms | 37652 KB |
#include <bits/stdc++.h> using namespace std; int v[1000001], X[1000001], n, POW[32], szX, szY, low[1000001], high[1000001]; int* vp, * xp; bool bit; struct poz { int val, i; }a[1000002], x[1000001], y[1000001]; bitset <1000001> b; int main() { cin >> n; int maxi = 0; for (int i = 0; i <= 30; i++) POW[i] = (1 << i); for (int i = 1; i <= n; i++) { cin >> v[i]; maxi = max(maxi, v[i]); } int l, r, m, poz1, poz2, poz; int res = 0, downLim, upLim, aux, sz, i; for (int i = 1; i <= n; i++) a[i].i = i, a[i].val = 0; for (int k = 0; k <= 29; k++) { bit = false; vp = v; vp++; xp = X; xp++; szX = szY = 0; for (i = 1; i <= n; i++) { if (*vp & 1) *xp += POW[k], b[i] = true; else b[i] = false; *vp >>= 1; vp++; xp++; } for (i = 1; i <= n; i++) if (b[a[i].i]) a[i].val += POW[k], y[++szY] = a[i]; else x[++szX] = a[i]; for (i = 1; i <= szX; i++) a[i] = x[i]; for (int i = 1; i <= szY; i++) a[szX + i] = y[i]; aux = (1 << k) + (1 << (k + 1)); downLim = POW[k]; upLim = POW[k + 1] - 1; l = 1, r = 1; while (r <= n && a[l].val + a[r].val < aux) r++; if (r == n + 1) { while (l <= n && a[l].val + a[n].val < aux) l++; r = n; } if (l != n + 1 && r != n + 1) { while (l < r) { while (l < r && a[l].val + a[r - 1].val >= aux) r--; bit ^= (n - r + 1) & 1; l++; } while (l <= n) bit ^= (n - (l++) + 1) & 1; } int last = n; for (int i = 1; i <= n; i++) { if (a[i].val + a[n].val < downLim) { low[i] = 0; continue; } while (last > 1 && a[i].val + a[last - 1].val >= downLim) last--; if (last < i) low[i] = i; else low[i] = last; } l = 1, r = n; while (l <= r && a[l].val + a[r].val > upLim) r--; while (l <= r) { high[l] = r; l++; while (l <= r && a[l].val + a[r].val > upLim) r--; } while (l <= n) high[l++] = 0; for (i = 1; i <= n; i++) if (low[i] && high[i] && low[i] <= high[i]) bit ^= (high[i] - low[i] + 1) & 1; if (bit) res += POW[k]; } cout << res; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 468 KB | Output is correct |
2 | Correct | 5 ms | 468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 611 ms | 37508 KB | Output is correct |
2 | Correct | 567 ms | 35148 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 611 ms | 37508 KB | Output is correct |
2 | Correct | 567 ms | 35148 KB | Output is correct |
3 | Correct | 815 ms | 37480 KB | Output is correct |
4 | Correct | 748 ms | 36324 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 468 KB | Output is correct |
2 | Correct | 5 ms | 468 KB | Output is correct |
3 | Correct | 105 ms | 4028 KB | Output is correct |
4 | Correct | 104 ms | 4040 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 468 KB | Output is correct |
2 | Correct | 5 ms | 468 KB | Output is correct |
3 | Correct | 611 ms | 37508 KB | Output is correct |
4 | Correct | 567 ms | 35148 KB | Output is correct |
5 | Correct | 815 ms | 37480 KB | Output is correct |
6 | Correct | 748 ms | 36324 KB | Output is correct |
7 | Correct | 105 ms | 4028 KB | Output is correct |
8 | Correct | 104 ms | 4040 KB | Output is correct |
9 | Correct | 1065 ms | 37652 KB | Output is correct |
10 | Correct | 1044 ms | 37472 KB | Output is correct |
11 | Correct | 1078 ms | 37472 KB | Output is correct |