제출 #124358

#제출 시각아이디문제언어결과실행 시간메모리
124358nxteru앵무새 (IOI11_parrots)C++14
100 / 100
12 ms1784 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][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 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...