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>
#include "transfer.h"
#define vi vector<int>
#define pb push_back
using namespace std;
vi get_attachment(vi source) {
int n = source.size();
vi ret;
int xo = 0;
for (int i = 0; i < n; i++)
xo ^= source[i];
ret.pb(xo);
for (int i = 0; (1 << i) < n; i++) {
xo = 0;
for (int j = 0; j < n; j++)
if ((j+1) & (1 << i))
xo ^= source[j];
ret.pb(xo);
}
return ret;
}
vi retrieve(vi data) {
int n = data.size() < 255 ? 63 : 255;
vi ret;
int xo = 0;
for (int i = 0; i < n; i++)
xo ^= data[i];
ret.pb(xo);
for (int i = 0; (1 << i) < n; i++) {
xo = 0;
for (int j = 0; j < n; j++)
if ((j+1) & (1 << i))
xo ^= data[j];
ret.pb(xo);
}
int k = data.size() - n;
if (ret[0] == data[n])
return vi(data.begin(), data.end() - k);
int idx = 0;
for (int i = 1; i < k; i++)
if (ret[i] != data[n + i])
idx |= (1 << (i-1));
if (idx)
data[idx-1] ^= 1;
return vi(data.begin(), data.end() - k);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |