# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67751 | ekrem | XOR Sum (info1cup17_xorsum) | C++98 | 1668 ms | 4232 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;
int n, a[N], top, ans, ans2;
void yz(int bit){
if(bit == 0)return;
yz(bit/2);
printf("%d",bit%2);
}
void yaz(int bit){
yz(bit);
puts("");
}
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d",&n);
for(int i = 1; i <= n; i++){
scanf("%d", a + i);
// yaz(a[i]);
top += a[i];
}
// cout << "AMK" << ((a[1] + a[2])^(a[1] + a[1])) << endl;
// cout <<(a[1]^a[2]) << endl;
// puts("");
for(int i = 1; i <= n; i++)
ans ^= (1 - n%2)*a[i];
for(int i = 1; i <= n; i++)
for(int j = i; j <= n; j++){
int zorla = 0;
for(int k = 0; (1<<k) <= a[i] or (1<<k) <= a[j]; k++){
if(a[i]&(1<<k) and a[j]&(1<<k))
zorla |= (1<<k);
if(k > 0 and (a[i]|a[j])&(1<<k) and zorla & (1<<(k - 1)))
zorla |= (1<<k);
}
// yaz(a[i]);
// yaz(a[j]);
// yaz(a[i] + a[j]);
// // yaz( (a[i]|a[j])*2 );
// yaz(a[i]^a[j] ^ ((zorla)*2) );
// puts("");
ans ^= ((zorla)*2);
}
// yaz(ans);
// yaz(ans2);
printf("%d\n",ans);
return 0;
}
Compilation message (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... |