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;
using ll = long long;
int n;
void ComputeAdvice(int* C, int _N, int K, int M) {
n = _N;
int bit = 31 - __builtin_clz(n - 1);
for (int j = 0;j < n;j++) {
for (int i = bit;i >= 0;i--) {
WriteAdvice((C[j] >> i) & 1);
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
bool in[100100];
queue<int> q[100100];
void Assist(unsigned char* A, int _N, int K, int R) {
n = _N;
int bit = 31 - __builtin_clz(n - 1);
for (int i = 0;i < R; i += bit) {
int now = 0;
for (int j = i;j < i + bit;j++) now = (now << 1) | A[j];
q[now].push(i / bit);
}
for (int i = 0;i < n;i++) q[i].push(n), in[i] = 1;
priority_queue<pair<int, int>> pq;
for (int i = 0;i < K;i++) pq.push({ q[i].front(), i });
for (int i = 0;i < n;i++) {
int req = GetRequest();
q[req].pop();
if (in[req]) continue;
in[req] = 1;
PutBack(pq.top().second);
in[pq.top().second] = 0;
pq.pop();
pq.push({ q[req].front(), 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... |