#include "transfer.h"
using namespace std;
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
vector<int> parity(vector<int> source) {
int log = sz(source) == 63 ? 6 : 8;
vector<int> par(log, 0);
for (int i = 0; i < sz(source); i++) {
for (int j = 0; j < log; j++) {
if ((i + 1) >> j & 1) par[j] ^= source[i];
}
}
return par;
}
vector<int> get_attachment(vector<int> source) {
vector<int> par = parity(source);
int x = 0;
for (int i = 0; i < sz(par); i++) {
x ^= par[i];
}
par.push_back(x);
return par;
}
vector<int> retrieve(vector<int> data) {
int cut = sz(data) == 70 ? 63 : 255;
vector<int> source(begin(data), begin(data) + cut);
vector<int> code(begin(data) + cut, end(data));
vector<int> par = parity(source);
int x = 0;
int p = 0;
for (int i = 0; i < sz(code) - 1; i++) {
if (code[i] != par[i]) x ^= 1 << i;
p ^= code[i];
}
if (code.back() != p) return source;
if (x != 0) source[x - 1] ^= 1;
return source;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
792 KB |
Output is correct |
2 |
Correct |
2 ms |
792 KB |
Output is correct |
3 |
Correct |
2 ms |
796 KB |
Output is correct |
4 |
Correct |
3 ms |
792 KB |
Output is correct |
5 |
Correct |
3 ms |
804 KB |
Output is correct |
6 |
Correct |
2 ms |
800 KB |
Output is correct |
7 |
Correct |
2 ms |
792 KB |
Output is correct |
8 |
Correct |
2 ms |
792 KB |
Output is correct |
9 |
Correct |
2 ms |
800 KB |
Output is correct |
10 |
Correct |
2 ms |
792 KB |
Output is correct |
11 |
Correct |
3 ms |
792 KB |
Output is correct |
12 |
Correct |
2 ms |
800 KB |
Output is correct |
13 |
Correct |
3 ms |
1092 KB |
Output is correct |
14 |
Correct |
2 ms |
792 KB |
Output is correct |
15 |
Correct |
2 ms |
800 KB |
Output is correct |
16 |
Correct |
2 ms |
800 KB |
Output is correct |
17 |
Correct |
2 ms |
800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
2512 KB |
Output is correct |
2 |
Correct |
180 ms |
2512 KB |
Output is correct |
3 |
Correct |
176 ms |
2656 KB |
Output is correct |
4 |
Correct |
175 ms |
2508 KB |
Output is correct |
5 |
Correct |
179 ms |
2512 KB |
Output is correct |
6 |
Correct |
175 ms |
2516 KB |
Output is correct |
7 |
Correct |
175 ms |
2508 KB |
Output is correct |
8 |
Correct |
181 ms |
2520 KB |
Output is correct |
9 |
Correct |
176 ms |
2516 KB |
Output is correct |
10 |
Correct |
175 ms |
2764 KB |
Output is correct |
11 |
Correct |
180 ms |
2508 KB |
Output is correct |
12 |
Correct |
220 ms |
2508 KB |
Output is correct |
13 |
Correct |
176 ms |
2516 KB |
Output is correct |
14 |
Correct |
183 ms |
2508 KB |
Output is correct |
15 |
Correct |
180 ms |
2512 KB |
Output is correct |
16 |
Correct |
181 ms |
2516 KB |
Output is correct |
17 |
Correct |
179 ms |
2516 KB |
Output is correct |
18 |
Correct |
184 ms |
2508 KB |
Output is correct |
19 |
Correct |
175 ms |
2508 KB |
Output is correct |