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<vector>
using namespace std;
vector<int> get_attachment(vector<int> source) {
int n = (int)source.size();
int XOR = 0, cnt = 0;
for(int i = 0;i < n;++i){
if(source[i]){
XOR ^= (i + 1);
cnt++;
}
}
vector<int>res;
if(n > 100){
for(int i = 0;i < 8;++i){
if(XOR & (1 << i)){
res.push_back(1);
}
else{
res.push_back(0);
}
}
}
else{
for(int i = 0;i < 6;++i){
if(XOR & (1 << i)){
res.push_back(1);
}
else{
res.push_back(0);
}
}
}
res.push_back(cnt & 1);
return res;
}
vector<int> retrieve(vector<int> data) {
int n = (int)data.size();
vector<int>res;
int XOR[2] = {}, par = 0, cnt = 0;
if(n > 100){
for(int i = 0;i < 255;++i){
if(data[i]){
XOR[0] ^= (i + 1);
cnt++;
}
res.push_back(data[i]);
}
for(int i = 0;i < 8;++i){
if(data[255 + i]){
XOR[1] += (1 << i);
}
}
par = data[263];
if(XOR[0] != XOR[1] && cnt % 2 != par){
int pos = XOR[0] ^ XOR[1];
res[pos - 1] ^= 1;
}
}
else{
for(int i = 0;i < 63;++i){
if(data[i]){
XOR[0] ^= (i + 1);
cnt++;
}
res.push_back(data[i]);
}
for(int i = 0;i < 6;++i){
if(data[63 + i]){
XOR[1] += (1 << i);
}
}
par = data[69];
if(XOR[0] != XOR[1] && cnt % 2 != par){
int pos = XOR[0] ^ XOR[1];
res[pos - 1] ^= 1;
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |