# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1139152 | KasymK | XOR Sum (info1cup17_xorsum) | C++20 | 593 ms | 8240 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 1e6+5;
int v[N], A[N];
int main(){
int n, answer=0;
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%d", v+i);
for(int j = 0; j <= 30; ++j){
int sm=0, op=0, ad=0;
if(j){
for(int i = 1; i <= n; ++i)
if(!(v[i]>>(j-1)&1))
A[++op]=v[i];
}
if(j){
for(int i = 1; i <= n; ++i)
if(v[i]>>(j-1)&1)
A[++op]=v[i];
}
if(j){
for(int i = 1; i <= n; ++i)
v[i]=A[i], A[i]=v[i]%(1<<j);
}
for(int i = 1; i <= n; ++i)
sm+=(!(v[i]>>j&1));
int id1=1, id2=n;
while(id1<=n){
while(A[id1]+A[id2]>=(1<<j))
id2--;
ad+=(n-id2), id1++;
}
for(int i = 1; i <= n; ++i)
ad+=(A[i]>=((1<<j)>>1));
int f=ad/2+sm*(n-sm);
if(f&1)
answer+=(1<<j);
}
printf("%d\n", answer);
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... |