Submission #64826

#TimeUsernameProblemLanguageResultExecution timeMemory
64826TadijaSebezParrots (IOI11_parrots)C++11
100 / 100
550 ms236160 KiB
#include "encoder.h" #include "encoderlib.h" #include <stdio.h> #include <algorithm> using namespace std; const int sz=90; const int H=576; struct Number { int a[sz]; void init(){ for(int i=0;i<sz;i++) a[i]=0;} Number(){ init();} Number operator + (Number b) const { Number c;c.init(); for(int i=0;i<sz;i++) { c.a[i]+=a[i]+b.a[i]; if(c.a[i]>255) c.a[i]-=256,c.a[i+1]++; } return c; } bool operator < (Number b) const { int i; for(i=sz-1;~i;i--) { if(a[i]<b.a[i]) return 1; if(b.a[i]<a[i]) return 0; } return 0; } } binom[H][H]; bool done=0; void encode(int n, int *m) { int i,j; if(!done) { for(i=0;i<H;i++) for(j=0;j<H;j++) binom[i][j].init(); for(i=1;i<H;i++) { binom[i][0].a[0]=1; for(j=1;j<=i;j++) { binom[i][j]=binom[i-1][j-1]+binom[i-1][j]; } } done=1; } Number my;my.init(); for(i=0;i<n;i++) my.a[i]=m[i]; Number sub;sub.init(); int go=5*n+255; for(i=0;i<n*5;i++) { while(my<(binom[go][5*n-i]+sub)) go--; send(5*n+255-go-1-i); sub=sub+binom[go][5*n-i]; go--; } }
#include "decoder.h" #include "decoderlib.h" #include <stdio.h> #include <algorithm> using namespace std; const int sz=90; const int H=576; struct Number { int a[sz]; void init(){ for(int i=0;i<sz;i++) a[i]=0;} Number(){ init();} Number operator + (Number b) const { Number c;c.init(); for(int i=0;i<sz;i++) { c.a[i]+=a[i]+b.a[i]; if(c.a[i]>255) c.a[i]-=256,c.a[i+1]++; } return c; } bool operator < (Number b) const { int i; for(i=sz-1;~i;i--) { if(a[i]<b.a[i]) return 1; if(b.a[i]<a[i]) return 0; } return 0; } } binom[H][H]; bool done=0; void decode(int n, int l, int *m) { int i,j; if(!done) { for(i=0;i<H;i++) for(j=0;j<H;j++) binom[i][j].init(); for(i=1;i<H;i++) { binom[i][0].a[0]=1; for(j=1;j<=i;j++) { binom[i][j]=binom[i-1][j-1]+binom[i-1][j]; } } done=1; } Number my;my.init(); sort(m,m+l); for(i=0;i<l;i++) { int x=m[i]; int go=5*n+255-x-i-1; my=my+binom[go][5*n-i]; } for(i=0;i<n;i++) output(my.a[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...