# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1006186 | HishamAlshehri | Data Transfer (IOI19_transfer) | C++17 | 5 ms | 5652 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>
using namespace std;
vector<int> get_attachment(vector<int> source) {
int x = 0, cnt = 0;
for (int i = 1; i <= source.size(); i++)
{
if (source[i - 1])
{
x ^= i;
cnt++;
}
}
vector<int>ans = source;
while (x)
{
ans.push_back(x % 2);
x /= 2;
}
ans.push_back(cnt % 2);
return ans;
}
vector<int> retrieve(vector<int> data) {
int x1 = 0, k = data[data.size() - 1], cnt = 0;
int n = (data.size() > 255 ? 255 : 63);
for (int i = 1; i <= n; i++)
{
if (data[i - 1])
{
cnt++;
x1 ^= i;
}
}
int x2 = 0;
for (int i = n + 1; i <= data.size() - 1; i++)
{
x2 += data[i - 1] * (1 << (i - n));
}
if (x1 != x2 && cnt % 2 != k)
data[(x2 ^ x1) - 1] ^= 1;
return vector<int>(data.begin(), data.begin() + n);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |