# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
470426 | Yazan_Alattar | XOR Sum (info1cup17_xorsum) | C++14 | 1681 ms | 16968 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 1000007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
int n, a[M], ans;
int main()
{
// ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
scanf("%d", &n);
for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
for(int j = 0; j < 31; ++j){
vector <int> v;
for(int i = 1; i <= n; ++i) v.pb(a[i] % (1 << (j + 1)));
sort(v.begin(), v.end());
bool add = 0;
for(int i = 0; i < v.size(); ++i){
int l = lower_bound(v.begin() + i, v.end(), (1 << j) - v[i]) - v.begin();
int r = lower_bound(v.begin() + i, v.end(), (1 << (j + 1)) - v[i]) - v.begin();
add ^= (r - l) % 2;
add ^= (n - (lower_bound(v.begin() + i, v.end(), (1 << j) + (1 << (j + 1)) - v[i]) - v.begin())) % 2;
}
cout << endl;
if(add) ans |= (1 << j);
}
cout << ans << endl;
return 0;
}
// Don't forget special cases. (n = 1?)
// Look for the constraints. (Runtime array? overflow?)
컴파일 시 표준 에러 (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... |