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"
const int LG = 13;
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i = 0; i < N; i++) {
for (int j = 0; j < LG; j++) {
WriteAdvice(C[i] >> j & 1);
}
}
}
#include "assistant.h"
const int maxn = 100025;
const int LG = 13;
int C[maxn];
int last[maxn];
int scaffold[maxn];
bool onScaffold[maxn];
void Assist(unsigned char *A, int N, int K, int R) {
for (int i = 0; i < N; i++) {
for (int j = 0; j < LG; j++) {
C[i] |= A[i*LG + j] * (1<<j);
}
}
for (int i = 0; i < K; i++)
scaffold[i] = i;
for (int i = 0; i < N; i++) {
int req = GetRequest();
if (!onScaffold[req]) {
for (int i = 0; i < N; i++) last[i] = maxn;
for (int j = N-1; j > i; j--)
last[C[j]] = j;
int pos = -1;
for (int j = 0; j < K; j++)
if(pos == -1 || last[scaffold[pos]] < last[scaffold[j]])
pos = j;
onScaffold[req] = true;
onScaffold[scaffold[pos]] = false;
PutBack(scaffold[pos]);
scaffold[pos] = req;
}
}
}
# | 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... |