This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |