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[]){
vector <int> v,v2;
for (int i=0;i<N;i++){
for (int j=0,k=1;j<4;j++,k*=4){
int x=M[i]/k%4;
for (int l=0;l<x;l++)
v.push_back(i*4+j);
for (int l=0;l<3-x;l++)
v2.push_back(i*4+j);
}
}
if (v.size()<v2.size())
for (int i:v)
send(i);
else{
for (int i:v2)
send(i);
for (int j=0;j<4;j++)
send(0);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <algorithm>
using namespace std;
int pw(int a, int b){
int res=1;
for (int i=0;i<b;i++)
res*=a;
return res;
}
void decode(int N, int L, int X[]){
sort(X,X+L);
int mode=1,res[N];
for (int i=0;i<N;i++)
res[i]=0;
if (L>=4&&X[0]==X[1]&&X[1]==X[2]&&X[2]==X[3]&&!X[0])
mode=0;
for (int i=(mode?0:4);i<L;i++)
res[X[i]/4]+=pw(4,X[i]%4);
for (int i=0;i<N;i++)
output((mode?res[i]:255-res[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... |