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<cstdio>
#include<cstring>
int conta[300];
inline int abs(int x) {return x<0?-x:x;}
void encode(int N, int M[])
{
memset(conta, 0, sizeof conta);
int tot = 0;
for(int i = 0; i < N; i++) {
for(int bit = 0; bit < 4; bit++) {
int cnt = (M[i] >> (2*bit))&3;
// while(cnt--) send(4*i+bit);
conta[4*i+bit] = cnt;
tot += cnt;
}
}
int ok = 0;
if(tot > N * 6) ok = 3, send(0), send(0), send(0), send(0);
for(int i = 0; i < 4*N; i++) {
int qtd = abs(ok - conta[i]);
while(qtd--) send(i);/*, printf("%d\n", abs(ok - conta[i]))*/;
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<cstdio>
#include<cstring>
#include<algorithm>
int cnt[10000];
inline int abs(int x) {return x<0?-x:x;}
void decode(int N, int L, int X[])
{
memset(cnt, 0, sizeof cnt);
for(int i = 0; i < L; i++)
cnt[X[i]]++;
// for(int i = 0; i < 4*N; i++)
// printf("%d ", cnt[i]);
// printf("\n");
int ok = 0;
if(cnt[0] >= 4) ok = 3, cnt[0] -= 4;
for(int i = 0; i < N; i++) {
int here = 0;
for(int j = 0; j < 4; j++) {
// printf("%d\n", ok);
here += (abs(ok-cnt[4*i+j])) << (2*j);
}
// printf("%d\n", here);
output(here);
}
}
# | 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... |