# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829827 | MrDeboo | Data Transfer (IOI19_transfer) | C++17 | 0 ms | 0 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;
std::vector<int> get_attachment(std::vector<int> v) {
n=v.size();
vector<int>voc((n==255?8:6));
for(int i=1;i<=n;i++){
for(int w=0;w<8;w++){
if(i&(1<<w))voc[w]^=v[i-1];
}
}
int g=0;
for(auto &i:voc)g^=i;
voc.push_back(g);
return voc;
}
std::vector<int> retrieve(std::vector<int> v) {
int nn=(n>100?9:7);
int n=v.size()-nn;
int g=0;
for(int i=v.size()-1;i>=v.size()-nn;i--)g^=v[i];
if(g!=v.back()){
for(int i=0;i<nn;i++)v.pop_back();
return v;
}
vector<int>voc(nn-1);
for(int i=1;i<=n;i++){
for(int w=0;w<nn-1;w++){
if(i&(1<<w))voc[w]^=v[i-1];
}
}
int f=0;
for(int i=0;i<nn-1;i++){
if(v[i+n]!=voc[i])f++;
}
for(int i=0;i<n;i++){
int k=0;
for(int w=0;w<nn-1;w++){
if(i&(1<<w)){
if(voc[w]!=v[w+n])k++;
}
}
if(k==f){
v[i]^=1;
break;
}
}
for(int i=0;i<nn;i++)v.pop_back();
return v;
}