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>
#pragma GCC optimize(2)
using namespace std;
#define N 200100
int n, res[N], used[N], nxt[N], last[N];
void ComputeAdvice(int *C, int n, int k, int m) {
priority_queue<pair<int,int>> q;
for(int i = 0; i < n; i++)
last[i] = n, used[i] = -1;
for(int i = n; i--;)
nxt[i] = last[C[i]], last[C[i]] = i;
for(int i = 0; i < k; i++)
q.push({last[i], used[i] = i});
for(int i = 0; i < n; i++){
if(used[C[i]]+1) {
res[used[C[i]]] = 1;
} else {
used[q.top().second] = -1;
q.pop();
}
used[C[i]] = k+i;
q.push({nxt[i], C[i]});
}
for(int i = 0; i < n+k; i++)
WriteAdvice(res[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
void Assist(unsigned char *A, int n, int k, int r) {
set<int> y;
priority_queue<int, vector<int>, greater<int>> q;
for(int i=0;i<k;i++){
if(A[i])
y.insert(i);
else
q.push(i);
}
for(int i=k;i<n+k;i++){
int c = GetRequest();
if(y.find(c) != y.end()){
y.erase(c);
} else {
PutBack(q.top());
q.pop();
}
if(A[i])
y.insert(c);
else
q.push(c);
}
}
# | 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... |