# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443430 | chicken337 | Data Transfer (IOI19_transfer) | C++14 | 69 ms | 2540 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 <bits/stdc++.h>
#include "transfer.h"
using namespace std;
vector<int> get_attachment(vector<int> source){
vector<int> ans; int xr = 0;
for(int i = 0; i < source.size(); i ++)
xr ^= source[i] * (i+1);
int last = 0, rounds = source.size() < 64 ? 6 : 8;
for(int i = 0; i < rounds; i ++){
ans.push_back(xr & 1);
if(xr & 1) last ^= 1;
xr >>= 1;
}
ans.push_back(last);
return ans;
}
vector<int> retrieve(vector<int> data){
int last = data.back(); data.pop_back();
int actual = 0, xr = 0;
int rounds = data.size() < 71 ? 6 : 8;
for(int i = 0; i < rounds; i ++){
xr <<= 1; xr += data.back();
if(data.back()) last ^= 1;
data.pop_back();
}
if(actual != last)
return vector<int>(data.begin(), data.end());
int x = 0;
for(int i = 0; i < data.size(); i ++)
x ^= data[i] * (i+1);
int err = xr ^ x;
if(err) data[err-1] ^= 1;
return data;
}
/**
int main(){
for(int i = 0; i < 100; i ++){
bool correct = true;
vector<int> gen_seq;
int len = rand() % 255 + 1;
for(int i = 0; i < len; i ++)
gen_seq.push_back(rand()&1);
cout << "Generation OK" << endl;
vector<int> attach = get_attachment(gen_seq);
if(len < 64 && attach.size()>7) correct = 0;
if(len > 63 && attach.size()>9) correct = 0;
cout << "Attachment OK" << endl;
vector<int> nans;
for(int it : gen_seq) nans.push_back(it);
for(int it : attach) nans.push_back(it);
vector<int> res = retrieve(nans);
cout << "Retrieval OK" << endl;
if(res.size() != len) correct = 0, cout << "WRONG LENGTH" << endl;
else for(int i = 0; i < res.size(); i ++)
if(res[i] != gen_seq[i]) correct = 0, cout << "WRONG ELEMENT" << endl;
cout << (correct ? "CORRECT" : "INCORRECT") << " with length " << len << endl;
}
}**/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |