#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) {
return parity(source);
}
vector<int> retrieve(vector<int> data) {
int cut = sz(data) == 69 ? 63 : 255;
vector<int> source(begin(data), begin(data) + cut);
vector<int> code(begin(data) + cut, end(data));
vector<int> par = parity(source);
int log = sz(par);
int x = 0;
for (int i = 0; i < log; i++) {
if (code[i] != par[i]) x ^= 1 << i;
}
if (x != 0) source[x - 1] ^= 1;
return source;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
800 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2504 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |