Submission #990648

#TimeUsernameProblemLanguageResultExecution timeMemory
990648AdamGSParrots (IOI11_parrots)C++17
99 / 100
4 ms1368 KiB
#include "encoder.h" #include "encoderlib.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() ll dpp[17][22]; vector<ll>koduj(ll x) { ll dlu=0; while(dpp[16][dlu]<=x) { x-=dpp[16][dlu]; ++dlu; } vector<ll>ans(16); ll c=16; while(dlu>0 && c>0) { if(c==1) { ++ans[0]; --dlu; continue; } if(dpp[c-1][dlu]<=x) { x-=dpp[c-1][dlu]; ++ans[c-1]; --dlu; } else --c; } return ans; } void encode(int n, int _T[]) { dpp[1][0]=1; for(int x=1; x<=16; ++x) { for(int y=1; y<=21; ++y) dpp[x][y]=dpp[x-1][y]+dpp[x][y-1]; } ll sum=0; rep(i, 22) sum+=dpp[16][i]; vector<ll>T(n); rep(i, n) T[i]=_T[i]; while(T.size()%4!=0) T.pb(0); if(n%2==1) T.pb(0); rep(i, (n+3)/4) { vector<ll>P=koduj(T[4*i]+256*T[4*i+1]+65536*T[4*i+2]+16777216*T[4*i+3]); rep(j, 16) rep(l, P[j]) send(16*i+j); } }
#include "decoder.h" #include "decoderlib.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() ll dp[17][22]; ll odkoduj(vector<ll>T) { ll x=0, sum=0; rep(i, 16) sum+=T[i]; rep(i, sum) x+=dp[16][i]; rep(i, 15) { rep(j, T[15-i]) { x+=dp[15-i][sum]; --sum; } } return x; } void decode(int n, int l, int _T[]) { dp[0][1]=1; for(int x=1; x<=16; ++x) { for(int y=1; y<=21; ++y) dp[x][y]=dp[x-1][y]+dp[x][y-1]; } vector<ll>T(256); rep(i, l) ++T[_T[i]]; vector<ll>ans(n+3); rep(i, (n+3)/4) { vector<ll>P(16); rep(j, 16) P[j]=T[16*i+j]; ll x=odkoduj(P); ans[4*i]=x%256; ans[4*i+1]=(x/256)%256; ans[4*i+2]=(x/65536)%256; ans[4*i+3]=x/16777216; } rep(i, n) output(ans[i]); }
#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...