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 <bits/stdc++.h>
#include "advisor.h"
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const int N = 1e5+5;
static queue<int> pos[N];
static bool inq[N];
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i = 0; i < N; ++i) pos[C[i]].emplace(i);
for(int i = 0; i < N; ++i) pos[i].emplace(N);
set<pii, greater<pii> > Q;
for(int i = 0; i < K; ++i) Q.emplace(pos[i].front(), i), inq[i] = true;
for(int i = 0; i < N; ++i) {
if(inq[C[i]]) {
Q.erase(pii(pos[C[i]].front(), i));
} else {
int v = Q.begin()->y; Q.erase(Q.begin());
inq[v] = false, inq[C[i]] = true;
for(int i = 0; i < 17; ++i) WriteAdvice(v >> i & 1);
}
pos[C[i]].pop();
Q.emplace(pos[C[i]].front(), C[i]);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
set<int> S;
for(int i = 0; i < K; ++i) S.emplace(i);
int ptr = 0;
for(int i = 0; i < N; ++i) {
int v;
if(S.count(v = GetRequest())) continue;
int val = 0;
for(int i = 0; i < 17; ++i) if(A[ptr++]) val |= (1 << i);
PutBack(val);
S.erase(val);
S.emplace(v);
}
}
# | 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... |