이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "advisor.h"
#include <bits/stdc++.h>
// TODO: check k = 1
using namespace std;
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()
const int MAXN = 1e6 + 10;
typedef pair<int, int> pll;
int n, k, F[MAXN];
vector<int> vec[MAXN];
inline int get(int c, int i) {
return *lower_bound(all(vec[c]), i);
}
void ComputeAdvice(int *C, int N, int K, int M) {
n = N, k = K;
for (int i = 0; i < n; i++)
vec[C[i]].push_back(i);
for (int i = 0; i < n; i++)
vec[i].push_back(n);
set<pll> st;
for (int i = 0; i < k; i++)
st.insert(pll(get(i, 0), i));
for (int i = 0; i < n; i++) {
int c = C[i];
if (st.find(pll(get(c, i), c)) != st.end()) {
F[i] = 1;
st.erase(pll(get(c, i), c));
} else {
F[i] = 0;
st.erase(prev(st.end()));
}
st.insert(pll(get(c, i + 1), c));
}
for (int i = 0; i < k; i++)
WriteAdvice(F[vec[i].front()]);
for (int i = 0; i < n; i++)
WriteAdvice(F[get(C[i], i + 1)]);
}
#include "assistant.h"
#include <bits/stdc++.h>
#define X first
#define Y second
#define debug(x) cerr << #x << ": " << x << endl;
#define sep ' '
using namespace std;
typedef pair<int, int> pll;
inline int wtf(int k) {
int ans = 1, res = 0;
while (ans < k)
ans *= 2, res++;
return res;
}
void Assist(unsigned char *A, int N, int K, int R) {
int n = N, k = K;
set<int> st, opt;
for (int i = 0; i < k; i++)
st.insert(i);
for (int i = 0; i < k; i++)
if (int(A[i]) == 0)
opt.insert(i);
for (int i = 0; i < n; i++) {
int c = GetRequest();
if (st.find(c) == st.end()) {
int x = *opt.begin();
PutBack(x);
opt.erase(x);
st.erase(x);
}
st.insert(c);
if (int(A[k + i]) == 0) opt.insert(c);
else if (opt.find(c) != opt.end()) opt.erase(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... |