제출 #251730

#제출 시각아이디문제언어결과실행 시간메모리
251730tinjyu최후의 만찬 (IOI12_supper)C++14
0 / 100
272 ms15676 KiB
#include <iostream> #include <algorithm> #include "advisor.h" using namespace std; long long int road[1000005],maxlen,ans[1000005],k,map[1000005],in[1000005],t[1000005],p[1000005],now[1000005]; struct cmp{ bool operator()(const int &a,const int &b) { return road[a]<road[b]; } }; void find(long long int x) { for(int i=1;i<=maxlen;i++) { char tmp; if(x%2==0)tmp=0; else tmp=1; WriteAdvice(tmp); //cout<<x%2<<" "; x/=2; } return ; } void ComputeAdvice(int *C, int N, int K, int M) { k=K; long long int x=1; while(x<k) { x*=2; maxlen++; } for(int i=0;i<N;i++)road[i]=100009; for(int i=N-1;i>=0;i--) { map[i]=road[C[i]]; road[C[i]]=i; } for(int i=0;i<N;i++)p[i]=-1; for(int i=0;i<K;i++) { t[i]=i; now[i]=i; p[i]=i; push_heap(now,now+i+1,cmp()); } //for(int i=0;i<K;i++)cout<<now[i].id<<" "; //cout<<endl; for(int i=0;i<N;i++) { if(p[C[i]]!=-1) { if(road[C[i]]!=100009)road[C[i]]=map[road[C[i]]]; continue; } else { pop_heap(now,now+K,cmp()); p[C[i]]=p[now[K-1]]; find(p[C[i]]); p[now[K-1]]=-1; road[C[i]]=map[road[C[i]]]; now[K-1]=C[i]; push_heap(now,now+K,cmp()); } } }
#include "assistant.h" #include <iostream> using namespace std; long long int a[100005],pp=0,malen,no[100005],pe[100005]; int find() { long long int tmp=0,x=1; for(int i=pp;i<pp+malen;i++) { if(a[i]=='1')tmp+=x; x*=2; } pp+=malen; return tmp; } void Assist(unsigned char *A, int N, int K, int R) { for(int i=0;i<R;i++) { //cout<<A[i]<<endl; a[i]=A[i]; } int k=K; long long int x=1; while(x<k) { x*=2; malen++; } for(int i=0;i<N;i++)pe[i]=-1; for(int i=0;i<k;i++) { no[i]=i; pe[i]=i; } for(int i=0;i<N;i++) { long long int tmp=GetRequest(); if(pe[tmp]!=-1) { continue; } long long int temp=find(); PutBack(no[temp]); pe[no[temp]]=-1; no[temp]=tmp; pe[tmp]=temp; } }
#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...