| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 521956 | boykut | XOR Sum (info1cup17_xorsum) | C++14 | 1682 ms | 14144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std ;
long long t[10000001];
void push(int v, int vl, int vr) {
}
void update(int l, int r, int x, int v, int vl, int vr) {
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
if (n <= 4000) {
long long x = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= i; j++) {
x ^= (a[i] + a[j]);
}
}
cout << x << '\n';
} else if (*max_element(a, a + n) <= 4000) {
int N = *max_element(a, a + n);
vector<int> cnt(N + 1, 0);
for (int i = 0; i < n; i++) cnt[a[i]]++;
long long x = 0;
for (int i = 0; i <= N; i++) {
if ((cnt[i] * (cnt[i] - 1) / 2 + cnt[i]) & 1)
x ^= (i + i);
if (cnt[i] & 1) {
for (int j = 0; j < i; j++) {
if (cnt[j] & 1)
x ^= (i + j);
}
}
}
cout << x << '\n';
} else if (*max_element(a, a + n) <= 1000000) {
int N = *max_element(a, a + n);
vector<int> cnt(N + 1, 0);
for (int i = 0; i < n; i++) cnt[a[i]]++;
long long x = 0;
for (int i = 0; i <= N; i++) {
if ((cnt[i] * (cnt[i] - 1) / 2 + cnt[i]) & 1)
x ^= (i + i);
}
vector<int> v;
for (int i = 0; i <= N; i++) {
if (cnt[i] & 1) v.push_back(i);
}
for (int i = 0; i < v.size(); i++) {
for (int j = 0; j < i; j++)
x ^= (v[i] + v[j]);
}
cout << x << '\n';
}
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... | ||||
