#include "transfer.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector<int> source){
int lim=source.size()+1;
lim=log2(lim);
int x=0;
for(int i=0;i<source.size();i++) if(source[i]==0) x^=(i+1);
vector<int>aux;
for(int i=lim-1;i>=0;i++){
if(x&(1<<i)) aux.push_back(1);
else aux.push_back(0);
}
return aux;
}
vector<int> retrieve(vector<int> data){
int lim=data.size();
lim=floor(log2(lim));
int id=data.size();
int res=0;
for(int i=0;i<lim;i++){
id--;
if(data[i]) res+=(1<<i);
data.pop_back();
}
int atx=0;
for(int i=0;i<data.size();i++) if(data[i]==0) atx^=(i+1);
if(atx==res) return data;
for(int i=0;i<data.size();i++){
int nx=atx;
nx^=(i+1);
if(nx==res){
data[i]=(data[i]+1)%2;
return data;
}
}
return data;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |