이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5;
int f[nmax + 1];
int lst[nmax + 1];
bool adv[2 * nmax + 1];
void ComputeAdvice(int *v, int N, int K, int M) {
for (int i = 0; i < N; ++ i)
lst[i] = 1 << 30;
int ind = N - 1;
int total = 0;
for (int i = N - 1; i >= 0; -- i) {
while (ind >= i && total > K) {
-- f[v[ind]];
if (f[v[ind]] == 0)
-- total;
-- ind;
}
if (total == K && lst[v[i]] > ind) {
adv[i + K] = 1;
}
if (f[v[i]] == 0)
++ total;
++ f[v[i]];
lst[v[i]] = i;
}
for (int i = K - 1; i >= 0; -- i) {
while (ind >= i && total > K) {
-- f[v[ind]];
if (f[v[ind]] == 0)
-- total;
-- ind;
}
if (total == K && lst[i] > ind) {
adv[i] = 1;
}
}
for (int i = 0; i < N + K; ++ i) {
WriteAdvice(adv[i]);
//cout << adv[i] << "\n";
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5;
bool viz[nmax + 1];
queue<int> q;
void Assist(unsigned char *A, int N, int K, int R) {
for (int i = 0; i < K; ++ i) {
viz[i] = 1;
if (A[i] == 1)
q.push(i);
}
for (int i = 0; i < N; ++ i) {
int c = GetRequest();
if (viz[c] == 0) {
assert(q.size());
PutBack(q.front());
viz[q.front()] = 0;
q.pop();
}
viz[c] = 1;
if (A[i + K] == 1)
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... |