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 <bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector<int> source) {
int i,n,j,cnt[10],ch=0,k;
n=source.size();
memset(cnt,0,sizeof cnt);
if(n==63) k=6;
else k=8;
for(i=0;i<n;i++){
if(source[i]!=1) continue;
for(j=0;j<k;j++){
if(((i+1)&(1<<j))!=0) cnt[j]=1-cnt[j];
}
ch=1-ch;
}
vector<int> ans;
ans.clear();
for(i=0;i<k;i++) ans.push_back(cnt[i]);
ans.push_back(ch);
return ans;
}
vector<int> retrieve(vector<int> data) {
int n=data.size(),k,cnt[10],ch=0,m=0,i,j;
if(n<100) n=63,k=6;
else n=255,k=8;
memset(cnt,0,sizeof cnt);
for(i=0;i<n;i++){
if(data[i]!=1) continue;
for(j=0;j<k;j++){
if(((i+1)&(1<<j))!=0) cnt[j]=1-cnt[j];
}
ch=1-ch;
}
vector<int> ans;
ans.clear();
if(ch==data[n+k]){
for(i=0;i<n;i++){
ans.push_back(data[i]);
}
return ans;
}else{
for(j=0;j<k;j++){
if(data[n+j]!=cnt[j]){
m+=(1<<j);
}
}
for(i=0;i<n;i++){
if((i+1)!=m) ans.push_back(data[i]);
else ans.push_back(1-data[i]);
}
return ans;
}
}
/*
15
1 011001010110110110100111110011010111111111111000101011100101001
2 011001010110110110100111110011010111111111111000101011100101001
3 011001010110110110100111110011010111111111111000101011100101001
4 011001010110110110100111110011010111111111111000101011100101001
6 011001010110110110100111110011010111111111111000101011100101001
9 011001010110110110100111110011010111111111111000101011100101001
8 011001010110110110100111110011010111111111111000101011100101001
10 011001010110110110100111110011010111111111111000101011100101001
63 011001010110110110100111110011010111111111111000101011100101001
52 011001010110110110100111110011010111111111111000101011100101001
51 011001010110110110100111110011010111111111111000101011100101001
54 011001010110110110100111110011010111111111111000101011100101001
2 011001010110110110100111110011010111111111111000101011100101001
12 011001010110110110100111110011010111111111111000101011100101001
50 011001010110110110100111110011010111111111111000101011100101001
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |