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"
static int LIB[257][7];
static void init() {
int arr[7] = {-1, -1, -1, -1, -1, -1, -1};
for (int i = 0; i < 257; ++i) {
for (int j = 0; j < 7; ++j) LIB[i][j] = arr[j];
int k;
for (k = 6; arr[k] == 3; --k);
++arr[k];
for (int l = k + 1; l <= 6; ++l) arr[l] = arr[k];
}
}
void encode(int N, int M[]) {
static bool isSet = true;
if (isSet) {
isSet = false;
init();
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j < 7; ++j) {
if (LIB[M[i] + 1][j] == -1) continue;
send(LIB[M[i] + 1][j] + (4 * i));
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <algorithm>
static int LIB[257][7];
static void init() {
int arr[7] = {-1, -1, -1, -1, -1, -1, -1};
for (int i = 0; i < 257; ++i) {
for (int j = 0; j < 7; ++j) LIB[i][j] = arr[j];
int k;
for (k = 6; arr[k] == 3; --k);
++arr[k];
for (int l = k + 1; l <= 6; ++l) arr[l] = arr[k];
}
}
static int find_num(int arr[7]) {
int l = 0, r = 256;
while(l <= r) {
const int m = (l + r) >> 1;
int fl;
for (int i = 0; i < 7; ++i) {
fl = arr[i] - LIB[m][i];
if (fl != 0) break;
}
if (fl == 0) return m;
else if (fl > 0) l = m + 1;
else r = m - 1;
}
return -1;
}
void decode(int N, int L, int X[]) {
static bool isSet = true;
if (isSet) {
isSet = false;
init();
}
std::sort(X, X + L);
int arr[7], arl = 0, nl = 3;
for (int i = 0; i < L; ++i) {
if (nl < X[i]) {
nl += 4;
for (int j = arl; j < 7; ++j) arr[j] = -1;
std::sort(arr, arr + 7);
const int n = find_num(arr) - 1;
if (n != -1) output(n);
arl = 0;
}
arr[arl++] = X[i] % 4;
}
for (int j = arl; j < 7; ++j) arr[j] = -1;
std::sort(arr, arr + 7);
const int n = find_num(arr) - 1;
if (n != -1) output(n);
}
# | 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... |