#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector<int> source) {
int n = source.size();
vector<int> ret(9);
for (int i = 0; i < n; i++) {
for (int j = 0; j < 8; j++) {
if ((i + 1) >> j & 1) {
ret[j] ^= source[i];
}
}
ret[8] ^= source[i];
}
return ret;
}
vector<int> retrieve(vector<int> data) {
int n = data.size();
int f = 0;
for (int i = 0; i < n - 9; i++) {
f ^= data[i];
}
if (f != data.back()) {
return vector<int>(data.begin(), data.begin() + n - 9);
}
vector<int> r(8);
for (int i = 0; i < n; i++) {
for (int j = 0; j < 8; j++) {
if ((i + 1) >> j & 1) {
r[j] ^= data[i];
}
}
}
int pos = 0;
for (int i = 0; i < 8; i++) {
if (r[i] != data[n - 9 + i]) {
pos += (1 << i);
}
}
pos--;
data[pos] ^= 1;
return vector<int>(data.begin(), data.begin() + n - 9);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
652 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
2492 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |