#include "encoder.h"
#include "encoderlib.h"
void encode(int N, int M[]){
int i,j,tt;
int tmp[100];
int a[100];
for(i=0; i<N; i++) tmp[i] = M[i];
if(N <= 32){
for(i=0; i<N; i++){
j = -1;
while(M[i] != 0){
tt = M[i] % 2;
M[i] /= 2;
j++;
if(tt == 0) continue;
send(8*i+j);
}
}
for(i=0; i<N; i++) M[i] = tmp[i];
return;
}
for(i=0; i<N; i++){
for(j=0; j<8; j++){
a[j] = M[i] % 2;
M[i] /= 2;
}
for(j=0; j<4; j++){
if(a[j*2] == 1 && a[(j*2)+1] == 1){
send(i*4+j); send(i*4+j); send(i*4+j);
}else if(a[j*2] == 1){
send(i*4+j);
}else if(a[(j*2)+1] == 1){
send(i*4+j); send(i*4+j);
}
}
}
for(i=0; i<N; i++) M[i] = tmp[i];
}
#include "decoder.h"
#include "decoderlib.h"
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
void decode(int N, int L, int X[]){
int i,j;
int t1,t2;
int ans[100];
int tmp[100][4];
if(N <= 32){
for(i=0; i<N; i++) ans[i] = 0;
for(i=0; i<L; i++){
t1 = X[i] / 8;
t2 = X[i] % 8;
ans[t1] += (1 << t2);
}
for(i=0; i<N; i++){
output(ans[i]);
}
return;
}
for(i=0; i<N; i++){
for(j=0; j<4; j++){
tmp[i][j] = 0;
}
}
for(i=0; i<L; i++){
t1 = X[i] / 4;
t2 = X[i] % 4;
tmp[t1][t2]++;
}
for(i=0; i<N; i++) ans[i] = 0;
for(i=0; i<N; i++){
for(j=0; j<4; j++){
if(tmp[i][j] == 1){
ans[i] += (1 << (2*j));
}else if(tmp[i][j] == 2){
ans[i] += (1 << ((2*j)+1));
}else if(tmp[i][j] == 3){
ans[i] += (1 << (2*j));
ans[i] += (1 << ((2*j)+1));
}
}
}
for(i=0; i<N; i++) output(ans[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1704 KB |
Output is correct |
2 |
Correct |
6 ms |
1744 KB |
Output is correct |
3 |
Correct |
7 ms |
1872 KB |
Output is correct |
4 |
Correct |
6 ms |
1872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2016 KB |
Output is correct |
2 |
Correct |
5 ms |
2176 KB |
Output is correct |
3 |
Correct |
5 ms |
2432 KB |
Output is correct |
4 |
Correct |
6 ms |
2432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2432 KB |
Output is correct |
2 |
Correct |
5 ms |
2432 KB |
Output is correct |
3 |
Correct |
6 ms |
2432 KB |
Output is correct |
4 |
Correct |
7 ms |
2432 KB |
Output is correct |
5 |
Correct |
7 ms |
2432 KB |
Output is correct |
6 |
Correct |
6 ms |
2432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
2432 KB |
Output is partially correct - P = 8.000000 |
2 |
Partially correct |
8 ms |
2432 KB |
Output is partially correct - P = 8.000000 |
3 |
Partially correct |
8 ms |
2432 KB |
Output is partially correct - P = 12.000000 |
4 |
Partially correct |
15 ms |
2432 KB |
Output is partially correct - P = 12.000000 |
5 |
Partially correct |
13 ms |
2528 KB |
Output is partially correct - P = 12.000000 |
6 |
Partially correct |
13 ms |
2536 KB |
Output is partially correct - P = 12.000000 |
7 |
Partially correct |
16 ms |
2536 KB |
Output is partially correct - P = 12.000000 |