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 <algorithm>
#include <queue>
#define INF 0x7fffffff
using namespace std;
typedef pair <int,int> ppair;
typedef pair <int,ppair> pppair;
static priority_queue <pppair> Q;
static int Time[200000], Check[100000], Out[200000];
void ComputeAdvice(int *C, int N, int K, int M) {
int i, Temp1, Temp2;
for(i=0 ; i<N ; i++)
Check[i]=INF;
for(i=N-1 ; i>=0 ; i--) {
Time[K+i]=Check[C[i]];
Check[C[i]]=K+i;
}
for(i=K-1 ; i>=0 ; i--)
Time[i]=Check[i];
for(i=0 ; i<N ; i++)
Check[i]=0;
for(i=0 ; i<K ; i++) {
Q.push(make_pair(Time[i],make_pair(i,i)));
Check[i]=1;
}
for(i=0 ; i<N ; i++)
if(!Check[C[i]]) {
Check[C[i]]=1;
Temp1=Q.top().second.first;
Temp2=Q.top().second.second;
Q.pop();
Check[Temp1]=0;
Out[Temp2]=1;
Q.push(make_pair(Time[K+i],make_pair(C[i],K+i)));
}
for(i=0 ; i<N+K ; i++)
WriteAdvice(Out[i]);
}
#include "assistant.h"
#include <algorithm>
#include <queue>
using namespace std;
typedef pair <int,int> ppair;
static priority_queue <ppair> Q;
static int Check[100000];
void Assist(unsigned char *A, int N, int K, int R) {
int i, Temp1, Temp2;
for(i=0 ; i<K ; i++) {
Q.push(make_pair(A[i],i));
Check[i]=1;
}
for(i=0 ; i<N ; i++)
{
Temp1=GetRequest();
if(!Check[Temp1]) {
Check[Temp1]=1;
Temp2=Q.top().second;
Q.pop();
Check[Temp2]=0;
PutBack(Temp2);
Q.push(make_pair(A[K+i],Temp1));
}
}
}
# | 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... |