This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "encoder.h"
#include "encoderlib.h"
int encode4(int i) {
if (i < 8) return i;
return (i >> 3) + 8;
}
void encode(int N, int M[]){
int i, position, value;
for (i = 0; i < N; i++) {
//position = encode4(i) << 4;
position = i << 4;
while(M[i] > 0) {
if (M[i] >= 56) {
send(position + encode4(56));
M[i] -= 56;
}
else {
value = 0;
if (M[i] >= 32) {
value += 32;
M[i] -= 32;
}
if (M[i] >= 16) {
value += 16;
M[i] -= 16;
}
if (M[i] >= 8) {
value += 8;
M[i] -= 8;
}
if (value > 0) {
send(position + encode4(value));
}
value = M[i];
M[i] -= 0;
send(position + encode4(value));
break;
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
int decode4(int i) {
if (i < 8) return i;
else return (i - 8) << 3;
}
int result[64];
void decode(int N, int L, int X[]){
int i, position;
for (i = 0; i < N; i++) result[i] = 0;
for (i = 0; i < L; i++) {
//position = decode4(X[i] >> 4);
//if (position > 0 && position < 8) X[i] -= (position << 4);
//else if(position >= 8) X[i] -= (((position >> 3) + 8) << 4);
position = X[i] >> 4;
result[position] += decode4(X[i] - (position << 4));
}
for (i = 0; i < N; i++) output(result[i]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |