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 <vector>
#include <iostream>
using namespace std;
#define v vector
void encode(int N, int M[])
{
v<int> mess1, mess2 = {255,255,255,255};
for(int i=0; i<N; i++){
for(int j=0; j<4; j++){
int pos=4*i+j;
int bit = 2*j;
bool bit1 = M[i] & (1<<bit);
bit++;
bool bit2 = M[i] & (1<<bit);
int num= bit1+2*bit2;
//cout<<M[i]<<" "<<pos<<" "<<num<<endl;
for(int i=0; i<num; i++) mess1.push_back(pos);
for(int i=0; i<3-num; i++) mess2.push_back(pos);
}
}
if(mess1.size()<mess2.size()){
for(int i:mess1) send(i);
} else{
for(int i:mess2) send(i);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <vector>
#include <iostream>
using namespace std;
#define v vector
void decode(int N, int L, int X[])
{
v<int> m(256, 0);
for(int i=0; i<L; i++) m[X[i]]++;
bool invert = (m[255]>=4);
if(invert) m[255]-=4;
for(int i=0; i<N; i++){
int out=0;
for(int j=0; j<4; j++){
int num=m[4*i+j];
if(num==1 || num==3) out |= 1<<(2*j);
if(num==2 || num==3) out |= 1<<(2*j+1);
}
//cout<<out<<endl;
if(invert) out = ~out;
output(out);
}
}
# | 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... |