#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) (int) (x).size()
#define pii pair<int,int>
#define f first
#define s second
void ComputeAdvice(int *C, int N, int K, int M){
int last[N];
int cnext[N];
for (int i = 0; i < N; i++) last[i] = N;
for (int i = N-1; i >= 0; i--){
cnext[i] = last[clist[i]];
last[clist[i]] = i;
}
bool vis[N];
memset(vis,0,sizeof(vis));
set<pii> all;
int cidx[N];
for (int i = 0; i < K; i++){ all.insert((pii) {-last[i],i}); vis[i] = 1; cidx[i] = i;}
bool res[N+K];
memset(res,0,sizeof(res));
int c,t;
for (int i = 0; i < N; i++){
c = clist[i];
if (vis[c]){
res[cidx[c]] = 1;
cidx[c] = i+K;
all.erase((pii) {i,c});
all.insert((pii) {-cnext[i],c});
continue;
}
cidx[c] = i+K;
t = (*all.begin()).s;
vis[t] = 0;
vis[c] = 1;
all.erase(all.begin());
all.insert((pii) {-cnext[i],c});
}
for (int i = 0; i < N+K; i++) WriteAdvice(res[i]);
return;
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) (int) (x).size()
#define pii pair<int,int>
#define f first
#define s second
void Assist(unsigned char *A, int N, int K, int R){
stack<int> o;
bool vis[N];
memset(vis,0,sizeof(vis));
for (int i = 0; i < K; i++){
vis[i] = 1;
if (A[i] == 0) o.push(i);
}
int c,t;
for (int i = 0; i < N; i++){
c = GetRequest();
if (vis[c]){
if (A[i+K] == 0) o.push(c);
continue;
}
t = o.top();
o.pop();
vis[t] = 0;
PutBack(t);
vis[c] = 1;
if (A[i+K] == 0) o.push(c);
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:16:19: error: 'clist' was not declared in this scope
16 | cnext[i] = last[clist[i]];
| ^~~~~
advisor.cpp:29:7: error: 'clist' was not declared in this scope
29 | c = clist[i];
| ^~~~~