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[])
{
int i;
for(i=0; i<N; i++) {
int now = i;
for (int j = 0; j < 4; ++j) {
if ((1 << j) & M[i]) {
now += (1 << (4 + j));
}
}
// std::cout << now << " + ";
send(now);
send(now);
now = i;
for (int j = 4; j < 8; ++j) {
if ((1 << j) & M[i]) {
now += (1 << (4 + j));
}
}
// std::cout << now << "\n";
send(now);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <vector>
void decode(int N, int L, int X[])
{
int i;
std::vector<std::vector<int>> res(N, std::vector<int>(2, -1));
for(i=0; i<L; i++) {
int num = 0;
for (int j = (1 << 4); j <= X[i]; j <<= 1) {
if (j & X[i]) {
num += (j >> 4);
}
}
int idx = 0;
for (int j = 0; j < 4; ++j) {
if ((1 << j) & X[i]) {
idx += (1 << j);
}
}
// std::cout << idx << " " << num << " <- " << X[i] << "\n";
if (res[idx][0] != -1) {
if (res[idx][0] == num) {
std::swap(res[idx][0], res[idx][1]);
}
} else {
res[idx][0] = num;
}
}
for (int i = 0; i < N; ++i) {
if (res[i][0] == -1) res[i][0] = 0;
if (res[i][1] == -1) res[i][1] = 0;
int num = ((res[i][0] << 4) + res[i][1]);
// std::cout << i << ": " << res[i][0] << " " << (res[i][1] << 4) << "\n";
output(num);
}
}
# | 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... |