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"
using namespace std;
#include <iostream>
vector<int> get_attachment(vector<int> source) {
const int N = source.size();
//assert(__builtin_popcount(N+1) == 1);
const int K = __lg(N+1)+1;
vector<int> attach(K);
for (int i = 0; i < N; i++) {
for (int b = 0; b < K-1; b++) {
if (((i+1) >> b) & 1) {
attach[b] ^= source[i];
}
}
attach.back() ^= source[i];
}
return attach;
}
vector<int> retrieve(vector<int> data) {
int N = data.size();
int K = __lg(N)+1;
N -= K;
vector<int> source(data.begin(), data.begin() + N);
vector<int> newattach = get_attachment(source);
int i = 0;
for (int b = 0; b < K-1; b++) {
if (newattach[b] != data[N+b]) {
i |= (1<<b);
}
}
i--;
if (newattach.back() != data.back()) {
if (i != -1) source[i] ^= 1;
}
return source;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |