Submission #1011328

#TimeUsernameProblemLanguageResultExecution timeMemory
1011328amirhoseinfar1385Last supper (IOI12_supper)C++17
43 / 100
202 ms14716 KiB
#include "advisor.h" #include<bits/stdc++.h> using namespace std; const int maxn=100000+10; set<pair<int,int>>st; set<int>wtf; int n,k,m,lgk; int allk[maxn],nxt[maxn],last[maxn],go[maxn],wh[maxn]; void wri(int x){ for(int i=0;i<=lgk;i++){ WriteAdvice((x>>i)&1); } } void ComputeAdvice(int *C, int N, int K, int M) { for(int i=0;i<20;i++){ if((K>>i)&1){ lgk=i; } } n=N; k=K; m=M; for(int i=0;i<maxn;i++){ last[i]=n+1; } for(int i=n-1;i>=0;i--){ nxt[i]=last[C[i]]; last[C[i]]=i; } for(int i=0;i<k;i++){ allk[i]=i; wtf.insert(i); go[i]=last[allk[i]]; wh[i]=i; st.insert(make_pair(last[allk[i]],i)); } for(int i=0;i<N;i++){ if(wtf.count(C[i])==1){ st.erase(make_pair(go[wh[C[i]]],wh[C[i]])); go[wh[C[i]]]=nxt[i]; st.insert(make_pair(nxt[i],wh[C[i]])); continue; } int z=(*st.rbegin()).second; wri(z); st.erase((*st.rbegin())); wtf.erase(allk[z]); wh[C[i]]=z; go[z]=nxt[i]; allk[z]=C[i]; wtf.insert(C[i]); st.insert(make_pair(nxt[i],z)); } }
#include "assistant.h" #include<bits/stdc++.h> using namespace std; const int maxn=100000+10; int all[maxn],lgk2,n2,k2,r2; set<int>st2; void Assist(unsigned char *A, int N, int K, int R) { for(int i=0;i<20;i++){ if((K>>i)&1){ lgk2=i; } } n2=N; k2=K; r2=R; for(int i=0;i<k2;i++){ all[i]=i; st2.insert(i); } int unnow=0; for(int i=0;i<n2;i++){ int req=GetRequest(); if(st2.count(req)==1){ continue; } int x=0; if(unnow>=R){ assert(0); } for(int i=0;i<=lgk2;i++){ if(A[unnow]==1){ x+=(1<<i); } unnow++; } PutBack(all[x]); st2.erase(all[x]); all[x]=req; st2.insert(req); } }
#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...