#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> get_attachment(std::vector<int> source) {
int sz=(source.size()<100)?6:8, sm=0, cnt=0;
vector<int> v;
for (int i=1; i<(1<<sz); i++) if (source[i]) sm^=i;
for (int i=0; i<sz; i++) v.push_back((sm>>i)&1), cnt+=((sm>>i)&1);
v.push_back(cnt%2);
return v;
}
std::vector<int> retrieve(std::vector<int> data) {
int sz=(data.size()<100)?6:8, n, sm=0, tmp=0;
if (sz==6) n=63;
else n=255;
for (int i=0; i<n; i++) if (data[i]) sm^=i;
for (int i=n; i<n+sz; i++) if (data[i]) tmp+=(i<<(i-n));
if (tmp==sm||(__builtin_popcount(tmp)%2)!=data.back()) return std::vector<int>(data.begin(), data.begin()+n);
int c=sm^tmp;
data[c]^=1;
//cout<<"debug "<<c<<'\n';
return std::vector<int>(data.begin(), data.begin()+n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
784 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
2516 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |