#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
void yeet(int n, vector<int> &v, vector<int> &source) {
for (int j = 0; (1 << j) <= n; j++) {
v.push_back(0);
for (int i = 1; i <= n; i++) {
if (i & 1 << j) {
v[j] ^= source[i-1];
}
}
}
}
vector<int> get_attachment(vector<int> source) {
int N = source.size();
vector<int> ret;
yeet(N, ret, source);
ret.push_back(0);
for (int i = 0; i < N; i++) {
ret.back() ^= source[i];
}
return ret;
}
vector<int> retrieve(vector<int> data) {
int N = data.size() < 255 ? 63 : 255;
int M = data.size();
vector<int> test;
yeet(N, test, data);
if (test == vector<int>(data.begin()+N, data.begin()+M-1)) {
return vector<int>(data.begin(), data.begin()+N);
}
bool p = 0;
for (int i = 0; i < N; i++) {
p ^= data[i];
}
if (p ^ data[M-1]) {
for (int i = 1; i <= N; i++) {
for (int j = 0; (1 << j) <= N; j++) {
if (i & 1 << j) {
test[j] ^= 1;
}
}
if (test == vector<int>(data.begin()+N, data.begin()+M-1)) {
data[i-1] ^= 1;
return vector<int>(data.begin(), data.begin()+N);
}
for (int j = 0; (1 << j) <= N; j++) {
if (i & 1 << j) {
test[j] ^= 1;
}
}
}
}
return vector<int>(data.begin(), data.begin()+N);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
648 KB |
Output is correct |
2 |
Correct |
12 ms |
644 KB |
Output is correct |
3 |
Correct |
12 ms |
728 KB |
Output is correct |
4 |
Correct |
12 ms |
652 KB |
Output is correct |
5 |
Correct |
12 ms |
740 KB |
Output is correct |
6 |
Correct |
9 ms |
644 KB |
Output is correct |
7 |
Correct |
9 ms |
644 KB |
Output is correct |
8 |
Correct |
9 ms |
652 KB |
Output is correct |
9 |
Correct |
9 ms |
732 KB |
Output is correct |
10 |
Correct |
9 ms |
736 KB |
Output is correct |
11 |
Correct |
9 ms |
676 KB |
Output is correct |
12 |
Correct |
9 ms |
644 KB |
Output is correct |
13 |
Correct |
11 ms |
728 KB |
Output is correct |
14 |
Correct |
9 ms |
720 KB |
Output is correct |
15 |
Correct |
12 ms |
732 KB |
Output is correct |
16 |
Correct |
13 ms |
640 KB |
Output is correct |
17 |
Correct |
11 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
595 ms |
2496 KB |
Output is correct |
2 |
Correct |
619 ms |
2492 KB |
Output is correct |
3 |
Correct |
617 ms |
2492 KB |
Output is correct |
4 |
Correct |
606 ms |
2456 KB |
Output is correct |
5 |
Correct |
611 ms |
2492 KB |
Output is correct |
6 |
Correct |
603 ms |
2492 KB |
Output is correct |
7 |
Correct |
607 ms |
2452 KB |
Output is correct |
8 |
Correct |
613 ms |
2500 KB |
Output is correct |
9 |
Correct |
603 ms |
2500 KB |
Output is correct |
10 |
Correct |
620 ms |
2504 KB |
Output is correct |
11 |
Correct |
595 ms |
2492 KB |
Output is correct |
12 |
Correct |
602 ms |
2504 KB |
Output is correct |
13 |
Correct |
595 ms |
2492 KB |
Output is correct |
14 |
Correct |
631 ms |
2500 KB |
Output is correct |
15 |
Correct |
630 ms |
2492 KB |
Output is correct |
16 |
Correct |
604 ms |
2492 KB |
Output is correct |
17 |
Correct |
602 ms |
2492 KB |
Output is correct |
18 |
Correct |
592 ms |
2500 KB |
Output is correct |
19 |
Correct |
603 ms |
2464 KB |
Output is correct |