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"
#include <bits/stdc++.h>
using namespace std;
namespace encoder {
mt19937 gen(69420);
int order[256];
vector<int> vals[256];
}
void encode(int N, int M[]) {
for (int i = 0; i < 256; i++) {
encoder::order[i] = i;
}
shuffle(encoder::order, encoder::order + 256, encoder::gen);
int cnt = 0;
for (int a = 0; a <= 4 && cnt < 256; a++) {
for (int b = a; b <= 4 && cnt < 256; b++) {
for (int c = b; c <= 4 && cnt < 256; c++) {
for (int d = c; d <= 4 && cnt < 256; d++) {
for (int e = d; e <= 4 && cnt < 256; e++) {
for (int f = e; f <= 4 && cnt < 256; f++) {
for (int g = f; g <= 4 && cnt < 256; g++) {
encoder::vals[encoder::order[cnt++]] = {a, b, c, d, e, f, g};
}
}
}
}
}
}
}
for (int i = 0; i < N; i++) {
for (auto val: encoder::vals[M[i]]) {
if (val > 0) {
send(i << 2 | (val - 1));
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
namespace decoder {
mt19937 gen(69420);
int order[256];
int id[5][5][5][5][5][5][5];
}
void decode(int N, int L, int X[]) {
for (int i = 0; i < 256; i++) {
decoder::order[i] = i;
}
shuffle(decoder::order, decoder::order + 256, decoder::gen);
int cnt = 0;
for (int a = 0; a <= 4 && cnt < 256; a++) {
for (int b = a; b <= 4 && cnt < 256; b++) {
for (int c = b; c <= 4 && cnt < 256; c++) {
for (int d = c; d <= 4 && cnt < 256; d++) {
for (int e = d; e <= 4 && cnt < 256; e++) {
for (int f = e; f <= 4 && cnt < 256; f++) {
for (int g = f; g <= 4 && cnt < 256; g++) {
decoder::id[a][b][c][d][e][f][g] = decoder::order[cnt++];
}
}
}
}
}
}
}
for (int i = 0; i < N; i++) {
vector<int> vals;
for (int j = 0; j < L; j++) {
if ((X[j] >> 2) == i) {
vals.push_back((X[j] & 3) + 1);
}
}
vals.resize(7);
sort(vals.begin(), vals.end());
output(decoder::id[vals[0]][vals[1]][vals[2]][vals[3]][vals[4]][vals[5]][vals[6]]);
}
}
# | 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... |