#include <bits/stdc++.h>
using namespace std;
#include "encoder.h"
#include "encoderlib.h"
#define L(i,j,k) for(int i=(j);i<=(k);i++)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)v.size())
void encode(int n, int vec[])
{
vector<array<int,7>> code(256);
map<array<int,7>,int> decode;
int nat=0;
array<int,7> at;
auto brute=[&](auto&&self,int id, int dat)->void{
if(nat>255)return;
if(id==7){
code[nat]=at;
decode[at]=nat;
nat++;
return;
}
while(dat<=3){
at[id]=dat;
self(self,id+1,dat);
dat++;
}
};
brute(brute,0,0);
int dat=0;
vector<int> resp;
L(i,0,n-1){
L(j,0,6)resp.push_back(dat+code[vec[i]][j]);
dat=resp.back();
}
L(i,0,sz(resp)-1)send(resp[i]);
return;
}
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
#define L(i,j,k) for(int i=(j);i<=(k);i++)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)v.size())
void decode(int n, int l, int vec[])
{
vector<array<int,7>> code(256);
map<array<int,7>,int> decode;
int nat=0;
array<int,7> at;
auto brute=[&](auto&&self,int id, int dat)->void{
if(nat>255)return;
if(id==7){
code[nat]=at;
decode[at]=nat;
nat++;
return;
}
while(dat<=3){
at[id]=dat;
self(self,id+1,dat);
dat++;
}
};
brute(brute,0,0);
sort(vec,vec+l);
int dat=0;
array<int,7> vecat;
for(int i=0;i<l;i+=7){
L(j,0,6)vecat[j]=vec[i+j]-dat;
dat=vec[i+6];
// cout<<decode[vecat]<<" ";
output(decode[vecat]);
}
}
# | 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... |