| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1310835 | nikoloz-ch | Data Transfer (IOI19_transfer) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "transfer.h"
using namespace std;
vector<int> get_attachment(vector<int> source){
int p = 0, k = 0; const int n = source.size(), kp = (n == 63 ? 6 : 8);
for(int i = 0; i < n; i++) if(source[i]) p ^= source[i];
auto t = bitset<kp>(p);
for(int i = 0; i < t.size(); i++) source.push_back(t[i]), k += (t[i] ? 1 : 0);
source.push_back(k % 2);
}
vector<int> retrieve(vector<int> data){
int p = 0, k = 0, kp = 0; const int n = data.size();
for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++) if(data[i]) p ^= data[i];
for(int i = n; i < n+(n >= 255 ? 8 : 6); i++){
if(data[i]) k += (1<<(i-n));
kp += (data[i] ? 1 : 0);
}
vector<int> ans;
if(data.back() != kp % 2){
for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++) ans.push_back(data[i]);
return ans;
}
for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++){
if(i == (p^k)) ans.push_back((data[i] ? 0 : 1));
else ans.push_back(data[i]);
}
return ans;
}
