#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> get_attachment(std::vector<int> source) {
int t = 0, n = (int)source.size();
if(n == 63) t = 6; //log2(63)
else t = 8; //log2(255)
vector<int> attachment;
int k = n+1;
for(int i = 0; i < t; ++i){
int checkbit = 0;
for(int start_idx = 0; start_idx < n; start_idx += k){
for(int idx = 0; idx < k/2; ++idx){
checkbit ^= source[start_idx + idx];
}
}
k /= 2;
attachment.push_back(checkbit);
}
int attachment_bit = 0;
for(int it : attachment)
attachment_bit ^= it;
attachment.push_back(attachment_bit);
return attachment;
}
std::vector<int> retrieve(std::vector<int> data) {
int check, N, K;
check = (int)data.size();
if(check == 70)
{N = 63; K = 7;}
else
{N = 255; K = 9;}
vector<int> src;
for(int j = 0; j < N; ++j)
src.push_back(data[j]);
int fcbit = 0;
for(int i = N; i < N+K-1; ++i)
fcbit ^= data[i];
if(fcbit != data[N+K-1])
return src;
int k = N+1, t = K-1;
string find = "";
for(int i = 0; i < t; ++i){
int checkbit = 0;
for(int start_idx = 0; start_idx < N; start_idx += k){
for(int idx = 0; idx < k/2; ++idx){
checkbit ^= data[start_idx + idx];
}
}
k /= 2;
if(checkbit == data[N+i])
find += "R";
else
find += "L";
}
int err_idx = 0;
int f = (N+1) / 2;
for(char x : find){
if(x == 'R') err_idx += f;
f /=2;
}
//if(err_idx == N) err_idx = N-1;
src[err_idx] ^= 1;
return src;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1016 KB |
Output is correct |
2 |
Correct |
8 ms |
1140 KB |
Output is correct |
3 |
Correct |
6 ms |
1148 KB |
Output is correct |
4 |
Correct |
6 ms |
1140 KB |
Output is correct |
5 |
Correct |
6 ms |
1012 KB |
Output is correct |
6 |
Correct |
6 ms |
1040 KB |
Output is correct |
7 |
Correct |
6 ms |
1148 KB |
Output is correct |
8 |
Correct |
6 ms |
1040 KB |
Output is correct |
9 |
Correct |
6 ms |
912 KB |
Output is correct |
10 |
Correct |
6 ms |
1144 KB |
Output is correct |
11 |
Correct |
6 ms |
1144 KB |
Output is correct |
12 |
Correct |
7 ms |
1040 KB |
Output is correct |
13 |
Correct |
7 ms |
1148 KB |
Output is correct |
14 |
Correct |
7 ms |
912 KB |
Output is correct |
15 |
Correct |
7 ms |
1144 KB |
Output is correct |
16 |
Correct |
7 ms |
1148 KB |
Output is correct |
17 |
Correct |
7 ms |
1144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
226 ms |
2500 KB |
Output is correct |
2 |
Correct |
206 ms |
2628 KB |
Output is correct |
3 |
Correct |
207 ms |
2672 KB |
Output is correct |
4 |
Correct |
220 ms |
2664 KB |
Output is correct |
5 |
Correct |
206 ms |
2668 KB |
Output is correct |
6 |
Correct |
210 ms |
2620 KB |
Output is correct |
7 |
Correct |
210 ms |
2672 KB |
Output is correct |
8 |
Correct |
210 ms |
2668 KB |
Output is correct |
9 |
Correct |
214 ms |
2668 KB |
Output is correct |
10 |
Correct |
205 ms |
2664 KB |
Output is correct |
11 |
Correct |
206 ms |
2680 KB |
Output is correct |
12 |
Correct |
236 ms |
2884 KB |
Output is correct |
13 |
Correct |
234 ms |
2668 KB |
Output is correct |
14 |
Correct |
245 ms |
2760 KB |
Output is correct |
15 |
Correct |
206 ms |
2628 KB |
Output is correct |
16 |
Correct |
211 ms |
2676 KB |
Output is correct |
17 |
Correct |
208 ms |
2684 KB |
Output is correct |
18 |
Correct |
216 ms |
2676 KB |
Output is correct |
19 |
Correct |
210 ms |
2676 KB |
Output is correct |