public class transfer {
int[] get_attachment(int[] source) {
int N = source.length;
int K;
int[] attach;
if(N == 63)
K = 7;
else
K = 9;
attach = new int[K];
for(int i = 0; i < K - 1; ++i) {
int xorsum = 0;
for(int j = 0; j < N; ++j)
if((j & (1 << i)) != 0)
xorsum = (xorsum ^ source[j]);
attach[i] = xorsum;
}
int totalxorsum = 0;
for(int j = 0; j < N; ++j)
totalxorsum ^= source[j];
attach[K - 1] = totalxorsum;
return attach;
}
int[] retrieve(int[] data) {
int N, K;
int[] rez;
if(data.length == 63 + 7) {
N = 63;
K = 7;
} else {
N = 255;
K = 9;
}
rez = new int[N];
int xorsum = 0;
for(int i = 0; i < N; ++i)
xorsum ^= data[i];
if(data[N + K - 1] != xorsum) {
int broken = 0;
for(int i = 0; i < K - 1; ++i) {
xorsum = 0;
for(int j = 0; j < N; ++j)
if((j & (1 << i)) != 0)
xorsum ^= data[j];
if(xorsum != data[N + i])
broken = (broken ^ (1 << i));
}
data[broken] ^= 1;
}
for(int j = 0; j < N; ++j)
rez[j] = data[j];
return rez;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
209 ms |
24112 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
404 ms |
91288 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |