# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
550090 | PunnyBunny | Data Transfer (IOI19_transfer) | C++17 | 44 ms | 2560 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 n = source.size(), sum = 0;
for (int i = 0; i < n; ++i) {
sum ^= (i + 1) * source[i];
}
int k = n == 63 ? 7 : 9;
vector<int> res(k);
for (int i = 0; i < 1 << k; ++i) {
int x = 0;
for (int j = 0; j < k - 1; ++j) x ^= (i >> j & 1) * (n + 1 + (1 << j));
x ^= (i >> (k - 1) & 1) * (n + 1);
if (x == sum) {
for (int j = 0; j < k; ++j) res[j] = i >> j & 1;
break;
}
}
return res;
}
std::vector<int> retrieve(std::vector<int> data) {
int n = data.size() > 100 ? 255 : 63, sum = 0;
for (int i = 0; i < n; ++i) {
sum ^= (i + 1) * data[i];
}
for (int i = n; i < data.size(); ++i) {
if (i == data.size() - 1) {
sum ^= data[i] * (n + 1);
} else {
sum ^= data[i] * (n + 1 + (1 << (i - n)));
}
}
if (sum > 0) data[sum - 1] ^= 1;
return {data.begin(), data.begin() + n};
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |