# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143762 | mahmoudbadawy | Data Transfer (IOI19_transfer) | C++17 | 75 ms | 2752 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"
using namespace std;
std::vector<int> get_attachment(std::vector<int> source) {
int x=0;
vector<int> v;
for(int i=0;i<source.size();i++)
{
if(source[i]==1) x^=(i+1);
}
int sz=(source.size()==63?6:8),xr=0;
while(sz--)
{
v.push_back(x%2); xr^=x%2; x/=2;
}
v.push_back(xr);
return v;
}
std::vector<int> retrieve(std::vector<int> data) {
int org=data.size()==7+63?63:255;
int xr=0;
for(int i=org;i<data.size();i++) xr^=data[i];
if(xr) return vector<int>(data.begin(),data.begin()+org);
for(int i=data.size()-2;i>=org;i--)
{
xr*=2; xr+=data[i];
}
int x=0;
for(int i=0;i<org;i++)
if(data[i]) x^=(i+1);
if(x!=xr) data[(x^xr)-1]^=1;
return vector<int>(data.begin(),data.begin()+org);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |