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[])
{
if(N<=32){
int idx=0;
for(int i=0;i<N;i++){
for(int bit=0;bit<8;bit++){
if(M[i]&(1<<bit))
send(idx+bit);
}
idx+=8;
}
}
else{
vector<int> bits(8*N,0);
int idx=0;
for(int i=0;i<N;i++){
for(int bit=0;bit<8;bit++){
if(M[i]&(1<<bit)) bits[idx+bit]=1;
}
idx+=8;
}
for(int i=0;i<8*N;i+=2){
int number=bits[i];
number+=((bits[i+1])<<1);
while(number--){
send(i);
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
void decode(int N, int L, int X[])
{
if(N<=32){
vector<int> binary(8*N,0);
sort(X,X+L);
for(int i=0;i<L;i++){
binary[X[i]]=1;
}
for(int i=0;i<8*N;i+=8){
int number=0;
for(int bit=0;bit<8;bit++){
if(binary[i+bit]) number+=(1<<bit);
}
output(number);
}
}
else{
vector<int> binary(8*N,0);
sort(X,X+L);
for(int i=0;i<L;i++){
int cnt=1;
while(i<L-1 && X[i]==X[i+1]) i++,cnt++;
if(cnt%2==1)
binary[ X[i] ]=1;
if(cnt>=2)
binary[ X[i]+1 ]=1;
}
for(int i=0;i<8*N;i+=8){
int number=0;
for(int bit=0;bit<8;bit++){
if(binary[i+bit]) number+=(1<<bit);
}
output(number);
}
}
}
# | 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... |