이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
void encode(int N, int M[]) {
vector<int> listeAjout,listeRetrait;
int nbVal=N,NB_BITS=8;
int val;
for (int i=0;i<nbVal;i++) {
val=M[i];
if (i<32) {
for (int j=0;j<NB_BITS;j++) {
if (val%2==0) {
listeRetrait.push_back(i*NB_BITS+j);
}
else {
listeAjout.push_back(i*NB_BITS+j);
}
val/=2;
}
}
else {
for (int j=0;j<NB_BITS;j++) {
if (val%2==0) {
listeRetrait.push_back((i-32)*NB_BITS+j);
listeRetrait.push_back((i-32)*NB_BITS+j);
}
else {
listeAjout.push_back((i-32)*NB_BITS+j);
listeAjout.push_back((i-32)*NB_BITS+j);
}
val/=2;
}
}
}
if ((int)listeAjout.size()<=(int)listeRetrait.size()+4) {
for (int i:listeAjout) {
send(i);
}
}
else {
for (int i:listeRetrait) {
send(i);
}
for (int i=0;i<4;i++) {
send(0);
}
}
}
#include<bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
void decode(int N, int L, int X[]) {
int TAILLE_MAX=256;
vector<int> nbOccu(TAILLE_MAX),rep(TAILLE_MAX);
int nbVal=N,nbCode=L,NB_BITS=8;
for (int i=0;i<nbCode;i++) {
nbOccu[X[i]]++;
}
if (nbOccu[0]<=3) {
for (int i=0;i<TAILLE_MAX;i++) {
if (nbOccu[i]%2==1) {
rep[i/NB_BITS]+=(1<<(i%NB_BITS));
}
if (nbOccu[i]/2==1) {
rep[i/NB_BITS+32]+=(1<<(i%NB_BITS));
}
}
for (int i=0;i<nbVal;i++) {
output(rep[i]);
}
}
else {
nbOccu[0]-=4;
for (int i=0;i<TAILLE_MAX;i++) {
if (nbOccu[i]%2==1) {
rep[i/NB_BITS]+=(1<<(i%NB_BITS));
}
if (nbOccu[i]/2==1) {
rep[i/NB_BITS+32]+=(1<<(i%NB_BITS));
}
}
for (int i=0;i<nbVal;i++) {
output(TAILLE_MAX-1-rep[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... |