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"
using namespace std;
void ComputeAdvice(int* C, int N, int K, int M) {
vector<int> pos(N, -1), nxt(N, N);
priority_queue<pair<int, int>> q;
for (int i = 0; i < N; ++i) {
if (pos[C[i]] != -1) {
nxt[pos[C[i]]] = i;
} else if (C[i] < K) {
q.emplace(i, C[i]);
}
pos[C[i]] = i;
}
vector<bool> in(N);
for (int i = 0; i < K; ++i) {
if (pos[i] == -1) {
q.emplace(N, i);
}
in[i] = true;
}
vector<vector<int>> pass(N);
for (int i = 0; i < N; ++i) {
if (in[C[i]]) {
pass[C[i]].push_back(0);
} else {
int take = q.top().second;
q.pop();
in[C[i]] = true;
in[take] = false;
pass[take].push_back(1);
}
q.emplace(nxt[i], C[i]);
}
vector<int> ptr(N);
for (int i = 0; i < N + K; ++i) {
int color = i < K ? i : C[i - K];
if (ptr[color] == (int) pass[color].size()) {
WriteAdvice(1);
} else {
WriteAdvice(pass[color][ptr[color]++]);
}
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char* A, int N, int K, int R) {
vector<bool> in(N);
queue<int> q;
for (int i = 0; i < K; ++i) {
in[i] = true;
if (A[i]) {
q.push(i);
}
}
for (int i = 0; i < N; ++i) {
int c = GetRequest();
if (!in[c]) {
in[c] = true;
in[q.front()] = false;
PutBack(q.front());
q.pop();
}
if (A[i + K]) {
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... |