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;
static ll c[26][26];
/*
vector<int>k;
void send(int t){
k.push_back(t);
}
*/
ll comb(int n,int r){
if(n<r)return 0;
return c[n-r][r];
}
vector<int>F(ll t){
vector<int>v(16,0);
int s=20;
for(int i=0;i<15;i++){
ll k=0;
for(int j=0;j<=s;j++){
k+=comb(14-i+j,j);
}
// cout<<t<<' '<<k<<endl;
if(t>k){
t-=k;
v[i]++;
s--;
i--;
}
}
v[15]=t;
return v;
}
void encode(int N, int M[]){
for(int i=0;i<=25;i++){
for(int j=0;j<=25;j++){
c[i][j]=0;
}
}
c[0][0]=1;
for(int i=0;i<=25;i++){
for(int j=0;j<=25;j++){
if(i)c[i][j]+=c[i-1][j];
if(j)c[i][j]+=c[i][j-1];
}
}
for(int i=0;i*4<N;i++){
ll t=0;
for(int j=i*4;j<i*4+4;j++){
t*=256;
if(N<=j)continue;
t+=M[j];
}
vector<int>v=F(t);
for(int j=0;j<16;j++){
for(int k=0;k<v[j];k++){
send(i*16+j);
}
}
}
}
/*
int main(){
int n,m[100];
cin>>n;
for(int i=0;i<n;i++){
cin>>m[i];
}
encode(n,m);
cout<<n<<' '<<k.size()<<endl;
for(int i:k){
cout<<i<<endl;
}
}
*/
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static int C[256],res[64];
static ll c[26][26];
/*
void output(int x){
cout<<x<<endl;
}
*/
ll dcomb(int n,int r){
if(n<r)return 0;
return c[n-r][r];
}
ll f(vector<int>v){
ll t=0;
int s=20;
for(int i=0;i<15;i++){
if(v[i]){
v[i]--;
for(int j=0;j<=s;j++){
t+=dcomb(14-i+j,j);
}
s--;
i--;
}
}
t+=v[15];
return t;
}
void decode(int N, int L, int X[]){
for(int i=0;i<=25;i++){
for(int j=0;j<=25;j++){
c[i][j]=0;
}
}
c[0][0]=1;
for(int i=0;i<=25;i++){
for(int j=0;j<=25;j++){
if(i)c[i][j]+=c[i-1][j];
if(j)c[i][j]+=c[i][j-1];
}
}
for(int i=0;i<256;i++){
C[i]=0;
}
for(int i=0;i<L;i++){
C[X[i]]++;
}
for(int i=0;i<16;i++){
vector<int>v(16,0);
for(int j=0;j<16;j++){
v[j]=C[i*16+j];
}
ll t=f(v);
for(int j=3;j>=0;j--){
res[i*4+j]=t%256;
t/=256;
}
}
for(int i=0;i<N;i++){
output(res[i]);
}
}
/*
int main(){
int n,l,x[100];
cin>>n>>l;
for(int i=0;i<l;i++){
cin>>x[i];
}
decode(n,l,x);
}
*/
# | 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... |