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[])
{
int n = 4;
for(int i=0;i<N;i++){
int idx = i*n + M[i] % n;
send(idx);
}
for(int i=0;i<N;i++){
int num = M[i] / n ;
int idx = i*n + N*n ;
int all = 0;
for(int j=0;j<2;j++){
int cur = ((num >> j) & 1);
all |= (cur << j);
}
idx+=all;
num = (num >> 2);
for(int j=0;j<=num;j++)
send(idx);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int N, int L, int X[])
{
int n = 4;
vector<int> mod(N);
vector<int> mul(N);
vector<int> frq(N);
for(int i=0;i<L;i++){
if(X[i] >= n*N){
int cur = X[i] - n*N;
int idx = cur / n ;
int b = cur % n;
mul[idx] = b;
frq[idx]++;
}
else{
int idx = X[i] / n ;
int b = X[i] % n;
mod[idx] = b;
}
}
for(int i=0;i<N;i++){
frq[i]--;
frq[i] = (frq[i] << 2);
mul[i]+=frq[i];
int ans = n * mul[i] + mod[i];
output(ans);
}
}
# | 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... |