# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
886955 | Zero_OP | XOR Sum (info1cup17_xorsum) | C++14 | 1606 ms | 14080 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define range(v) begin(v), end(v)
#define compact(v) v.erase(unique(range(v)), end(v))
template<class T> bool minimize(T& a, T b){
if(a > b) return a = b, true;
return false;
}
template<class T> bool maximize(T& a, T b){
if(a < b) return a = b, true;
return false;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
void Zero_OP(){
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; ++i){
cin >> a[i];
}
int ans = 0;
for(int target = 30; target >= 0; --target){ //last target bits
for(int i = 0; i < n; ++i){
a[i] %= (1 << (target + 1));
}
sort(range(a));
ll cur = 0;
int j = n, k = n, l = n;
for(int i = 0; i < n; ++i){
maximize(j, i);
maximize(k, i);
maximize(l, i);
while(i < j and a[i] + a[j - 1] >= (1 << target)) --j;
while(i < k and a[i] + a[k - 1] > ((1 << (target + 1)) - 1)) --k;
while(i < l and a[i] + a[l - 1] >= (1 << (target + 1)) + (1 << target)) --l;
cur += k - j;
cur += n - l;
}
if(cur & 1) ans ^= (1 << target);
}
cout << ans << '\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
#define task "antuvu"
if(fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
Zero_OP();
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... |