| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1303610 | nicolo_010 | Data Transfer (IOI19_transfer) | C++20 | 0 ms | 0 KiB |
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
vector<int> get_attachment(vector<int> source) {
vector<int> a;
int x=0;
for (int i=0; (int)source.size(); i++) {
if (source[i]) x ^= (i+1);
}
int last=0;
if (source.size()<64) {
for (int i=0; i<6; i++) {
a.push_back(x&1);
last ^= (x&1);
x /= 2;
}
}
else {
for (int i=0; i<8; i++) {
a.push_back(x&1);
last ^= (x&1);
x /= 2;
}
}
a.push_back(last);
return a;
}
vector<int> retrieve(vector<int> data) {
int last = data.back();
data.pop_back();
int x=0, nlast=0;
if (data.size()<71) {
for (int i=0; i<6; i++) {
x *= 2;
x += data.back();
nlast ^= (data.back());
data.pop_back();
}
}
else {
for (int i=0; i<8; i++) {
x *= 2;
x += data.back();
nlast ^= (data.back());
}
}
vector<int> a = data;
if (nlast != last) {
return data;
}
int ax=0;
for (int i=0; i<data.size(); i++) {
if (data[i]) x ^= (i+1);
}
int off = ax ^ x;
if (off==0) return data;
data[error-1] = 1-data[error-1];
return data;
}
