#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector<int> source){
int n=source.size(), x=0, k=0, p=0;
for(int i=1; i<=n; i++) x^=(source[i-1]*i);
if(n==63) k=6;
else k=8;
vector<int> ans(k+1);
for(int i=0; i<k; i++){
if(x&1){
ans[k-i-1]=1;
p++;
}
else ans[k-i-1]=0;
x/=2;
}
ans[k]=p&1;
return ans;
}
vector<int> retrieve(vector<int> data){
int n=data.size(), x=0, x2=0, p=0, k=0; bool flag=true;
if(n==70){
k=7;
for(int i=0; i<6; i++){
x+=pow(2,5-i)*(data[63+i]);
p+=data[63+i];
}
}else{
k=9;
for(int i=0; i<8; i++){
x+=pow(2,7-i)*(data[255+i]);
p+=data[255+i];
}
}
if(p%2!=data[n-1]) flag=false;
vector<int> ans=vector<int>(data.begin(),data.end()-k);
if(flag){
for(int i=1; i<=n-k; i++) x2^=data[i-1]*i;
ans[(x^x2)-1]^=1;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |