#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 = 7;
}
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[K - 1] ^= source[i];
}
return ret;
}
vector<int> retrieve(vector<int> data) {
int K = 9;
if (data.size() < 255) {
K = 7;
}
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
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
4 |
Correct |
6 ms |
640 KB |
Output is correct |
5 |
Correct |
6 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
640 KB |
Output is correct |
7 |
Correct |
4 ms |
648 KB |
Output is correct |
8 |
Correct |
5 ms |
652 KB |
Output is correct |
9 |
Correct |
5 ms |
648 KB |
Output is correct |
10 |
Correct |
5 ms |
720 KB |
Output is correct |
11 |
Correct |
5 ms |
640 KB |
Output is correct |
12 |
Correct |
5 ms |
640 KB |
Output is correct |
13 |
Correct |
5 ms |
640 KB |
Output is correct |
14 |
Correct |
7 ms |
724 KB |
Output is correct |
15 |
Correct |
5 ms |
640 KB |
Output is correct |
16 |
Correct |
5 ms |
648 KB |
Output is correct |
17 |
Correct |
6 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
303 ms |
2492 KB |
Output is correct |
2 |
Correct |
313 ms |
2464 KB |
Output is correct |
3 |
Correct |
290 ms |
2476 KB |
Output is correct |
4 |
Correct |
323 ms |
2484 KB |
Output is correct |
5 |
Correct |
292 ms |
2488 KB |
Output is correct |
6 |
Correct |
309 ms |
2484 KB |
Output is correct |
7 |
Correct |
298 ms |
2484 KB |
Output is correct |
8 |
Correct |
327 ms |
2484 KB |
Output is correct |
9 |
Correct |
303 ms |
2484 KB |
Output is correct |
10 |
Correct |
314 ms |
2436 KB |
Output is correct |
11 |
Correct |
297 ms |
2488 KB |
Output is correct |
12 |
Correct |
318 ms |
2500 KB |
Output is correct |
13 |
Correct |
287 ms |
2484 KB |
Output is correct |
14 |
Correct |
315 ms |
2496 KB |
Output is correct |
15 |
Correct |
283 ms |
2492 KB |
Output is correct |
16 |
Correct |
323 ms |
2480 KB |
Output is correct |
17 |
Correct |
312 ms |
2488 KB |
Output is correct |
18 |
Correct |
300 ms |
2484 KB |
Output is correct |
19 |
Correct |
328 ms |
2484 KB |
Output is correct |