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;
void encode(int N, int M[]) {
int a = 0, b = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 4; j++) {
int v = ((M[i]&(1<<(j*2)))>0) + 2*((M[i]&(1<<(j*2+1)))>0);
a += v, b += 3-v;
}
}
bool flag = (b < a);
if (flag) for (int i = 0; i < 4; i++) send(0);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 4; j++) {
int v = ((M[i]&(1<<(j*2)))>0) + 2*((M[i]&(1<<(j*2+1)))>0);
if (flag) v = 3-v;
while (v--) send(i*4 + j);
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int N, int L, int X[]) {
vector <int> cnt(1<<8);
vector <int> ans(N);
for (int i = 0; i < L; i++)
cnt[X[i]]++;
bool flag = cnt[0] >= 4;
if (flag) {
for (int i = 0; i < N; i++)
ans[i] = (1<<8)-1;
cnt[0] -= 4;
}
for (int i = 0; i < L; i++) {
if (!cnt[X[i]]) continue;
cnt[X[i]]--;
int id = X[i] / 4, k = X[i] % 4;
if (flag) {
ans[id] -= (1<<(k*2));
} else {
ans[id] += (1<<(k*2));
}
}
for (int i = 0; i < N; i++)
output(ans[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... |