# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
318955 | NachoLibre | XOR Sum (info1cup17_xorsum) | C++14 | 1255 ms | 30300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1000006, M = 30;
int n, a[N], x;
vector<pair<int, int> > v, nv[2];
void nextsort(int b) {
nv[0].clear();
nv[1].clear();
b = (1 << b);
for(int i = 0; i < n; ++i) {
v[i].first |= (a[v[i].second] & b);
nv[!!(v[i].first & b)].push_back(v[i]);
}
v.clear();
for(int i = 0; i < 2; ++i) {
for(int j = 0; j < nv[i].size(); ++j) {
v.push_back(nv[i][j]);
}
}
}
int xorcount(int b) {
int r = n, dr = 0;
b = (1 << b);
for(int i = 0; i < n; ++i) {
while(r > i && ((v[r - 1].first + v[i].first) & b)) --r;
dr ^= ((n - r) & 1);
if(r == i) ++r;
}
return dr;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
v.push_back({0, i});
if((n & 1) ^ 1) x ^= a[i];
}
for(int i = 1; i < M; ++i) {
nextsort(i - 1);
x ^= (xorcount(i) << i);
}
cout << x << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |