# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
210775 | Alexa2001 | Data Transfer (IOI19_transfer) | C++17 | 228 ms | 2928 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 "transfer.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector<int> source)
{
vector<int> a;
int n;
if(source.size() < 64) n = 6;
else n = 8;
int xor_bits = 0;
int i, j;
for(i=0; i<n; ++i)
{
int bit = 0;
for(j=0; j<source.size(); ++j)
if(!(j & (1<<i))) bit ^= source[j];
a.push_back(bit);
xor_bits ^= bit;
}
a.push_back(xor_bits);
return a;
}
vector<int> retrieve(vector<int> data)
{
int n;
if(data.size() < 64 + 7) n = 6;
else n = 8;
int xor_bits = 0, m = data.size() - n - 1;
vector<int> b(n), ans;
int i, j;
for(i=0; i<n; ++i)
{
int bit = 0;
for(j=0; j<m; ++j)
if(!(j & (1<<i))) bit ^= data[j];
b[i] = bit;
}
int bad = 0;
for(i=0; i<n; ++i)
{
if(b[i] != data[m + i]) bad |= (1<<i);
xor_bits ^= data[m + i];
}
ans = data;
ans.resize(m);
if(bad && xor_bits == data.back())
ans[bad ^ ((1<<n) - 1)] ^= 1;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |