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;
std::vector<int> get_attachment(std::vector<int> source) {
int sz=(source.size()<100)?6:8, sm=0, cnt=0;
vector<int> v;
for (int i=1; i<(1<<sz); i++) if (source[i-1]) sm^=i;
for (int i=0; i<sz; i++) v.push_back((sm>>i)&1), cnt+=((sm>>i)&1);
v.push_back(cnt%2);
return v;
}
std::vector<int> retrieve(std::vector<int> data) {
int sz=(data.size()<100)?6:8, n, sm=0, tmp=0;
if (sz==6) n=63;
else n=255;
for (int i=0; i<n; i++) if (data[i]) sm^=(i+1);
for (int i=n; i<n+sz; i++) if (data[i]) tmp+=(1<<(i-n));
if (tmp==sm||(__builtin_popcount(tmp)%2)!=data.back()) return std::vector<int>(data.begin(), data.begin()+n);
int c=sm^tmp;
data[c-1]^=1;
return std::vector<int>(data.begin(), data.begin()+n);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |