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"
void encode(int N, int M[])
{
if (N <= 32) {
for (int i = 0; i < N; i++) {
for (int j = 7; j >= 0; j--) {
if ((M[i] >> j) & 1) {
send(8 * i + j);
}
}
}
}
else {
for (int i = 0; i < N; i++) {
for (int j = 3; j >= 0; j--) {
for (int k = 0; k < ((M[i] >> (2 * j)) & 3); k++) {
send(4 * i + j);
}
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
void decode(int N, int L, int X[]) {
int freq[256];
for (int i = 0; i < 256; i++) {
freq[i] = 0;
}
for (int i = 0; i < L; i++) {
freq[X[i]]++;
}
if (N <= 32) {
for (int i = 0; i < N; i++) {
int val = 0;
for (int j = 7; j >= 0; j--) {
val <<= 1;
val |= freq[8 * i + j];
}
output(val);
}
} else {
for (int i = 0; i < N; i++) {
int val = 0;
for (int j = 3; j >= 0; j--) {
val <<= 2;
val |= freq[4 * i + j];
}
output(val);
}
}
}
# | 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... |