# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829564 | MODDI | Data Transfer (IOI19_transfer) | C++14 | 0 ms | 0 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>
#include "transfer.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
vector<int> get_attachment(vector<int> source){
int x = 0;
vi ret = source;
for(int i = 0; i < (int)source.size(); i++){
if(source[i] == 1)
x ^= (i+1);
}
int ones = 0;
if(source.size() < 64){
for(int i = 0; i < 6; i++){
ret.pb(x&1);
if(x&1) ones++;
x >>=1;
}
}
else
{
for(int i = 0; i < 8; i++){
ret.pb(x&1);
if(x&1) ones++;
x>>=1;
}
}
if(ones % 2 == 1)
ret.pb(1);
else
ret.pb(0);
return ret;
}
vector<int> retrieve(vector<int> data){
int last = data.back();
data.pop_back();
int ac_last = 0, x = 0;
if(data.size() < 71){
for(int i = 0; i < 6; i++){
x<<=1;
x += data.back();
if(data.back()) ac_last = 1 - ac_last;
data.pop_back();
}
}
else{
for(int i = 0; i < 8; i++){
x<<=1;
x += data.back();
if(data.back()) ac_last = 1 - ac_last;
data.pop_back();
}
}
if(ac_last != last) return data;
int ac_x = 0;
for(int i = 0; i < (int)data.size(); i++){
if(data[i]) ac_x ^= (i+1);
}
int error = ac_x ^ x;
if(error == 0) return data;
data[error-1] = 1 - data[error-1];
return data;
}