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;
#define lli long long int
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
void encode(int N, int M[])
{
lli n,num,uno,cero,a,b;
n = N;
uno = 0;
cero = 0;
rep(i,0,n-1) {
num = M[i];
a = num;
rep(i,1,8) {
if (a&1) uno++;
else cero++;
a/=2;
}
}
//cero = uno;
if (cero > uno) {
rep(i,1,4) send(0);
rep(i,0,n-1) {
num = M[i];
a = i << 2;
rep(j,0,3) {
b = (num&3);
rep(x,1,b) send(a+j);
num>>=2;
}
}
}
else {
rep(i,0,n-1) {
num = M[i];
a = i << 2;
rep(j,0,3) {
b = (num&3);
repa(x,2,b) send(a+j);
num>>=2;
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
void decode(int N, int L, int X[])
{
lli num[70][4],n,a,b,pos;
n = N;
lli cont = 0;
rep(i,0,L-1) if (X[i] == 0) cont++;
if (cont > 3) {
rep(i,0,n-1) {
rep(j,0,3) num[i][j] = 0;
}
cont=4;
rep(i,0,L-1) {
if (X[i] == 0 && cont > 0) {
cont--;
continue;
}
a = X[i];
pos = a>>2;
b = (a&3);
num[pos][b]++;
//debugsl(a);
//debugsl(pos);
//debugsl(b);
//debug(num[pos][b]);
}
rep(i,0,n-1) {
a = 0;
a += num[i][0];
a += num[i][1] * 4;
a += num[i][2] * 16;
a += num[i][3] * 64;
output(a);
}
}
else {
rep(i,0,n-1) {
rep(j,0,3) num[i][j] = 3;
}
rep(i,0,L-1) {
a = X[i];
pos = a>>2;
b = (a&3);
num[pos][b]--;
//debugsl(a);
//debugsl(pos);
//debugsl(b);
//debug(num[pos][b]);
}
rep(i,0,n-1) {
a = 0;
a += num[i][0];
a += num[i][1] * 4;
a += num[i][2] * 16;
a += num[i][3] * 64;
output(a);
}
}
}
# | 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... |