#include "transfer.h"
std::vector<int> get_attachment(std::vector<int> source) {
const int n = source.size();
int sum = 0;
for (int i = 0; i < n; ++i) {
sum ^= source[i] * (i + 1);
}
const int k = n == 63 ? 6 : 8;
std::vector<int> ret(k + 1);
int bit = 0;
for (int i = 0; i < k; ++i) {
ret[i] = sum >> i & 1;
bit ^= ret[i];
}
ret[k] = bit;
return ret;
}
std::vector<int> retrieve(std::vector<int> data) {
const int n = data.size();
const int k = n == 70 ? 6 : 8;
const int m = n - k - 1;
std::vector<int> ret(data.begin(), data.begin() + m);
int sum = 0, bit = 0;
for (int i = 0; i < k; ++i) {
sum += data[m + i] << i;
bit ^= data[m + i];
}
if (bit != data[m + k]) {
return ret;
}
int actual = 0;
for (int i = 0; i < m; ++i) {
actual ^= data[i] * (i + 1);
}
if (actual == sum) {
return ret;
} else {
ret[(actual ^ sum) - 1] ^= 1;
return ret;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
700 KB |
Output is correct |
2 |
Correct |
3 ms |
728 KB |
Output is correct |
3 |
Correct |
2 ms |
696 KB |
Output is correct |
4 |
Correct |
2 ms |
692 KB |
Output is correct |
5 |
Correct |
1 ms |
628 KB |
Output is correct |
6 |
Correct |
3 ms |
724 KB |
Output is correct |
7 |
Correct |
3 ms |
636 KB |
Output is correct |
8 |
Correct |
3 ms |
632 KB |
Output is correct |
9 |
Correct |
2 ms |
636 KB |
Output is correct |
10 |
Correct |
3 ms |
636 KB |
Output is correct |
11 |
Correct |
2 ms |
636 KB |
Output is correct |
12 |
Correct |
2 ms |
636 KB |
Output is correct |
13 |
Correct |
3 ms |
632 KB |
Output is correct |
14 |
Correct |
2 ms |
628 KB |
Output is correct |
15 |
Correct |
2 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
1 ms |
636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
2396 KB |
Output is correct |
2 |
Correct |
40 ms |
2440 KB |
Output is correct |
3 |
Correct |
43 ms |
2480 KB |
Output is correct |
4 |
Correct |
41 ms |
2472 KB |
Output is correct |
5 |
Correct |
58 ms |
2480 KB |
Output is correct |
6 |
Correct |
40 ms |
2480 KB |
Output is correct |
7 |
Correct |
39 ms |
2480 KB |
Output is correct |
8 |
Correct |
41 ms |
2432 KB |
Output is correct |
9 |
Correct |
39 ms |
2476 KB |
Output is correct |
10 |
Correct |
40 ms |
2504 KB |
Output is correct |
11 |
Correct |
41 ms |
2476 KB |
Output is correct |
12 |
Correct |
42 ms |
2476 KB |
Output is correct |
13 |
Correct |
39 ms |
2440 KB |
Output is correct |
14 |
Correct |
40 ms |
2472 KB |
Output is correct |
15 |
Correct |
40 ms |
2476 KB |
Output is correct |
16 |
Correct |
40 ms |
2472 KB |
Output is correct |
17 |
Correct |
39 ms |
2508 KB |
Output is correct |
18 |
Correct |
42 ms |
2608 KB |
Output is correct |
19 |
Correct |
39 ms |
2480 KB |
Output is correct |