| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 389286 | i_am_noob | XOR Sum (info1cup17_xorsum) | C++17 | 638 ms | 38020 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define rep(n) rep1(i,n)
#define rep1(i,n) rep2(i,0,n)
#define rep2(i,a,b) for(int i=a; i<(b); ++i)
#define rep3(i,a,b) for(int i=a; i>=(b); --i)
#define pb push_back
#define pii pair<int,int>
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << " " << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T x){cerr << x << endl;}
template<typename T, typename ...S> void _do(T x, S... y){cerr << x << ", ";_do(y...);}
#else
#define bug(...) 49
#endif
const int maxn=1000005;
int n,a[maxn],ans,cur;
vector<int> vec[2];
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0);
cin >> n;
rep(n) cin >> a[i];
rep(n) vec[a[i]&1].pb(a[i]);
rep1(j,30){
int cnt=0;
bug(j);
for(auto i: vec[0]) bug(i);
for(auto i: vec[1]) bug(i);
rep1(k,2){
cur=sz(vec[k])-1;
rep(sz(vec[k])){
while(cur>=0&&((vec[k][i]+vec[k][cur])>>j&1)) cur--;
cnt+=sz(vec[k])-1-cur;
//if((sz(vec[k])-1-cur)&1) ans^=pow2(j);
}
}
rep(n) if((a[i]<<1)&pow2(j)) cnt++;
cnt/=2;
if(cnt&1) ans^=pow2(j);
cur=0;
rep(sz(vec[0])){
while(cur<sz(vec[1])&&((vec[0][i]+vec[1][cur])>>j&1)) cur++;
if(cur&1) ans^=pow2(j);
}
vector<int> tmp[2];
for(auto i: vec[0]) if(!(i&pow2(j+1))) tmp[0].pb(i);
for(auto i: vec[1]) if(!(i&pow2(j+1))) tmp[0].pb(i);
for(auto i: vec[0]) if(i&pow2(j+1)) tmp[1].pb(i);
for(auto i: vec[1]) if(i&pow2(j+1)) tmp[1].pb(i);
vec[0]=tmp[0],vec[1]=tmp[1];
}
cout << ans << "\n";
}컴파일 시 표준 에러 (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... | ||||
