#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<<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<<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!=m) ans.push_back(data[i]);
else ans.push_back(1-data[i]);
}
return ans;
}
}
/*
5
0 011001010110110110100111110011010111111111111000101011100101001
7 011001010110110110100111110011010111111111111000101011100101001
62 011001010110110110100111110011010111111111111000101011100101001
63 011001010110110110100111110011010111111111111000101011100101001
-1 011001010110110110100111110011010111111111111000101011100101001
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
628 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
2476 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |