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;
typedef long long ll;
void encode(int n, int m[]){
ll dp[40][40],rs=0;
for(int i=0;i<27;i++)dp[0][i]=1;
for(int i=0;i<35;i++){
for(int j=0;j<27;j++){
if(i)dp[i][j]=dp[i-1][j];
if(j)dp[i][j]+=dp[i][j-1];
}
}
for(int i=0;i<n;i+=7){
ll s=0,p=0;
for(int j=i;j<n&&j<i+7;j++,p++){
s*=256LL;
s+=ll(m[j]);
}
p*=5;
s++;
for(int j=p-1;j>=0;j--){
for(int k=0;k<min(256-rs,27LL);k++){
if(dp[j][k]>=s){
send(rs+k);
if(k>0)s-=dp[j][k-1];
break;
}
}
}
rs+=27;
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void decode(int n, int l, int x[]){
ll dp[40][40],rs=0,xs=0;
sort(x,x+l);
for(int i=0;i<27;i++)dp[0][i]=1;
for(int i=0;i<35;i++){
for(int j=0;j<27;j++){
if(i)dp[i][j]=dp[i-1][j];
if(j)dp[i][j]+=dp[i][j-1];;
}
}
for(int i=0;i<n;i+=7){
ll s=0,p=0;
for(int j=i;j<n&&j<i+7;j++,p++);
p*=5;
for(int j=p-1;j>=0;j--)if(x[xs+j]-rs>0)s+=dp[j][x[xs+j]-rs-1];
xs+=p;
rs+=27;
p/=5;
for(ll i=p-1;i>=0;i--)output((s>>(i*8LL))&255LL);
}
}
# | 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... |