Submission #38848

#TimeUsernameProblemLanguageResultExecution timeMemory
38848andy627Last supper (IOI12_supper)C++14
0 / 100
391 ms15232 KiB
#include "advisor.h" #include <stdio.h> #include <vector> #include <algorithm> using namespace std; int n,k,m,bit; int c[111111]; int cnt[111111],pos[111111],col[111111]; vector<int> era; void wri(int num){ for(int i=0;i<bit;i++){ if(num&(1<<i)) WriteAdvice(1); else WriteAdvice(0); } } void ComputeAdvice(int *C,int N,int K,int M){ n=N; k=K; m=M; for(int i=0;i<n;i++) c[i]=C[i]; for(;k>(1<<bit);bit++); //printf("%d\n",bit); for(int i=0;i<n;i++) cnt[c[i]]++; for(int i=0;i<k;i++) col[i]=i; for(int i=0;i<k;i++) pos[i]=i; for(int i=k;i<n;i++) pos[i]=-1; for(int i=0;i<n;i++){ if(pos[c[i]]>=0) wri(0); else{ if(era.empty()){ pos[c[i]]=0; pos[col[0]]=-1; col[0]=c[i]; wri(1); } else{ int eco=era.back(); era.pop_back(); pos[c[i]]=pos[eco]; pos[eco]=-1; col[pos[c[i]]]=c[i]; wri(pos[c[i]]+1); } } cnt[c[i]]--; if(!cnt[c[i]]) era.push_back(c[i]); } }
#include "assistant.h" #include <stdio.h> int nn,kk,rr,bitt,poss; int a[111111],coll[111111]; int read_(){ int num=0; for(int i=0;i<bitt;i++) num+=a[poss+i]*(1<<i); poss+=bitt; return num; } void Assist(unsigned char *A, int N, int K, int R) { nn=N; kk=K; rr=R; for(int i=0;i<nn;i++) a[i]=A[i]; for(;kk>(1<<bitt);bitt++); for(int i=0;i<kk;i++) coll[i+1]=i; for(int i=0;i<nn;i++){ int num=read_(); num--; //printf("%d ",num); if(num){ PutBack(coll[num]); coll[num]=GetRequest(); } } }
#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...