Submission #124367

#TimeUsernameProblemLanguageResultExecution timeMemory
124367nxteruParrots (IOI11_parrots)C++14
17 / 100
9 ms1976 KiB
#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][32],rs=0; for(int i=0;i<32;i++)dp[0][i]=1; for(int i=0;i<40;i++){ for(int j=0;j<32;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+=8){ ll s=0,p=0; for(int j=i;j<n&&j<i+8;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,32LL);k++){ if(dp[j][k]>=s){ send(rs+k); if(k>0)s-=dp[j][k-1]; break; } } } rs+=32; } }
#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][32],rs=0,xs=0; sort(x,x+l); for(int i=0;i<32;i++)dp[0][i]=1; for(int i=0;i<40;i++){ for(int j=0;j<32;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+=8){ ll s=0,p=0; for(int j=i;j<n&&j<i+8;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+=32; p/=5; for(ll i=p-1;i>=0;i--)output((s>>(i*8LL))&255LL); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...