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;
typedef long long ll;
#define sz(v) int(v.size())
vector<int> get_attachment(vector<int> a) {
int n = sz(a), B = 31-__builtin_clz(n);
assert(n&(1<<B)), assert((1<<(B+1))>n);
vector<int> ans{0};
for (auto v : a) ans.back() ^= v;
ans.push_back(ans.back());
for (int i = 0; i <= B; i++){
ans.push_back(0);
for (int j = 0; j < n; j++) if ((j>>i)&1) ans.back() ^= a[j];
}
return ans;
}
vector<int> retrieve(vector<int> a) {
int n=-1;
if (sz(a) >= 255) n = 255;
else n = 63;
vector<int> ans(a.begin(), a.begin()+n);
if (a[n] != a[n+1]){
return ans;
}
{
int c=0;
for (int i = 0; i < n; i++) c ^= a[i];
if (c == a[n]) return ans;
}
int idx=0;
int B = 31-__builtin_clz(n);
assert(n&(1<<B)), assert((1<<(B+1))>n);
for (int i = 0; i <= B; i++){
int rl=0;
for (int j = 0; j < n; j++) if ((j>>i)&1) rl ^= a[j];
if (rl != a[n+2+rl]){
idx ^= 1<<i;
}
}
ans[idx] ^= 1;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |