# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143837 | SpeedOfMagic | Data Transfer (IOI19_transfer) | C++17 | 161 ms | 2652 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;
vector<int> get_attachment(vector<int> source) {
int x = 0;
vector<int> res;
for (int i = 0; i < source.size(); i++)
x ^= (i + 1) * source[i];
int lim = (source.size() == 63) ? 6 : 8;
int X = 0;
for (int i = 0; i < lim; i++) {
int d = (x & (1 << i)) != 0;
res.push_back(d);
X ^= d;
}
res.push_back(X);
return res;
}
vector<int> retrieve(vector<int> data) {
//for (int i = 0; i < data.size(); i++) cout << data[i]; cout << endl;
int st;
int len;
if (data.size() == 70) {
st = 63;
len = 6;
} else {
st = 255;
len = 8;
}
int x = 0;
int X = 0;
for (int i = st; i < st + len; i++) {
x += (1 << (i - st)) * data[i];
X ^= data[i];
}
int rx = 0;
for (int i = 0; i < st; i++)
rx ^= (i + 1) * data[i];
vector<int> ans;
if (x != rx) {
if (X != data.back()) { //problem with xor
for (int i = 0; i < st; i++)
ans.push_back(data[i]);
} else { //problem with the main part
for (int i = 0; i < st; i++) {
if ((rx ^ (i + 1)) == x)
ans.push_back(1 - data[i]);
else
ans.push_back(data[i]);
}
}
} else //problem with the last bit, or there's no problem
for (int i = 0; i < st; i++)
ans.push_back(data[i]);
//for (int i : ans) cout << i; cout << endl;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |