Submission #923241

#TimeUsernameProblemLanguageResultExecution timeMemory
923241bachhoangxuanLast supper (IOI12_supper)C++17
100 / 100
109 ms7704 KiB
#include "advisor.h" #include<bits/stdc++.h> using namespace std; const int maxn = 100005; #define pii pair<int,int> #define fi first #define se second int lst[maxn],nxt[maxn]; void ComputeAdvice(int *C, int N, int K, int M) { for(int i=0;i<N;i++) lst[i]=N; for(int i=N-1;i>=0;i--){ nxt[i]=lst[C[i]]; lst[C[i]]=i; } set<pii> s; for(int i=0;i<K;i++) s.insert({lst[i],i}); vector<int> c(N+1,0); for(int i=0;i<N;i++){ if(s.find({i,C[i]})!=s.end()) c[i]=1,s.erase({i,C[i]}); else s.erase(*s.rbegin()); s.insert({nxt[i],C[i]}); } for(int i=0;i<K;i++) WriteAdvice(c[lst[i]]); for(int i=0;i<N;i++) WriteAdvice(c[nxt[i]]); }
#include "assistant.h" #include<bits/stdc++.h> using namespace std; void Assist(unsigned char *A, int N, int K, int R) { set<int> d0,d1; for(int i=0;i<K;i++){ if(A[i]) d1.insert(i); else d0.insert(i); } for(int i=0;i<N;i++){ int x=GetRequest(); if(d1.find(x)!=d1.end()) d1.erase(x); else{ PutBack(*d0.begin()); d0.erase(d0.begin()); } if(A[K+i]) d1.insert(x); else d0.insert(x); } }
#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...