# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
864606 | ThylOne | Data Transfer (IOI19_transfer) | C++14 | 44 ms | 2596 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> source) {
int lenCode = 7;
if(source.size()!=63){
lenCode = 9;
}
int xorIndex=0;
int xor0;
for(int i=1;i<=source.size();i++){
if(source[i-1]){
xorIndex^=i;
}
}
vector<int> bits(lenCode);
int sum=0;
for(int i=0;i<lenCode-1;i++){
bits[i]=(xorIndex>>i)&1;
sum+=bits[i];
}
bits[lenCode-1]=sum&1;
return bits;
}
std::vector<int> retrieve(std::vector<int> data) {
int lenCode=9;
if(data.size()==63+7){
lenCode=7;
}
int len = data.size()-lenCode;
int xorIndex=0;
for(int i=1;i<=len;i++){
if(data[i-1]){
xorIndex^=i;
}
}
int restitution=0;
int sum=0;
for(int i=0;i<lenCode-1;i++){
if(data[i+len]){
restitution+=(1<<i);
}
sum+=data[i+len];
}
int fake = xorIndex^restitution;
vector<int> real=data;
for(int i=0;i<lenCode;i++)real.pop_back();
if(fake>0 && !((sum&1)!=data[data.size()-1]))
real[fake-1] = !real[fake-1];
return real;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |