#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector<int> source) {
int K = 9;
if (source.size() == 63) {
K = 8;
}
int n = source.size();
vector<int> ret(K);
for (int i = 0; i < n; i++) {
for (int j = 0; j < K - 1; j++) {
if ((i + 1) >> j & 1) {
ret[j] ^= source[i];
}
}
ret[8] ^= source[i];
}
return ret;
}
vector<int> retrieve(vector<int> data) {
int K = 9;
if (data.size() < 255) {
K = 8;
}
int n = data.size();
int f = 0;
for (int i = 0; i < n - K; i++) {
f ^= data[i];
}
vector<int> ans(n - K);
for (int i = 0; i < n - K; i++) {
ans[i] = data[i];
}
if (f == data.back()) {
return ans;
}
vector<int> r(8);
for (int i = 0; i < n - K; i++) {
for (int j = 0; j < K - 1; j++) {
if ((i + 1) >> j & 1) {
r[j] ^= data[i];
}
}
}
int pos = 0;
for (int i = 0; i < K - 1; i++) {
if (r[i] != data[n - K + i]) {
pos += (1 << i);
}
}
if (pos != 0) {
pos--;
ans[pos] ^= 1;
}
return ans;
}
/*
5
0 011001010110110110100111110011010111111111111000101011100101001
7 011001010110110110100111110011010111111111111000101011100101001
62 011001010110110110100111110011010111111111111000101011100101001
63 011001010110110110100111110011010111111111111000101011100101001
-1 011001010110110110100111110011010111111111111000101011100101001
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
776 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
289 ms |
2444 KB |
Output is correct |
2 |
Correct |
285 ms |
2496 KB |
Output is correct |
3 |
Correct |
287 ms |
2496 KB |
Output is correct |
4 |
Correct |
283 ms |
2448 KB |
Output is correct |
5 |
Correct |
290 ms |
2488 KB |
Output is correct |
6 |
Correct |
285 ms |
2488 KB |
Output is correct |
7 |
Correct |
286 ms |
2488 KB |
Output is correct |
8 |
Correct |
278 ms |
2488 KB |
Output is correct |
9 |
Correct |
296 ms |
2496 KB |
Output is correct |
10 |
Correct |
289 ms |
2496 KB |
Output is correct |
11 |
Correct |
288 ms |
2496 KB |
Output is correct |
12 |
Correct |
285 ms |
2472 KB |
Output is correct |
13 |
Correct |
292 ms |
2448 KB |
Output is correct |
14 |
Correct |
283 ms |
2488 KB |
Output is correct |
15 |
Correct |
285 ms |
2488 KB |
Output is correct |
16 |
Correct |
287 ms |
2452 KB |
Output is correct |
17 |
Correct |
285 ms |
2480 KB |
Output is correct |
18 |
Correct |
284 ms |
2496 KB |
Output is correct |
19 |
Correct |
281 ms |
2448 KB |
Output is correct |