#include "advisor.h"
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int nx[200006], color[100006];
bool res[200006];
void ComputeAdvice(int *c, int n, int k, int m) {
vector<int> v;
for (int i = 0; i < k; i++) v.push_back(i);
for (int i = 0; i < n; i++) v.push_back(c[i]);
for (int i = 0; i < n + k; i++) nx[i] = 2e9;
for (int i = 0; i < n; i++) color[i] = -1;
for (int i = 0; i < n + k; i++) {
if (color[v[i]] != -1) nx[color[v[i]]] = i;
color[v[i]] = i;
}
set<pair<int, int>> q;
for (int i = 0; i < k; i++) q.insert({ nx[i], i });
for (int i = k; i < n + k; i++) {
auto it = q.lower_bound({ i, -1 });
if (it == q.end() || it->first != i) {
it = q.end();
it--;
res[it->second] = true;
}
q.erase(it);
q.insert({ nx[i], i });
}
for (int i = 0; i < n + k; i++) WriteAdvice(res[i]);
}
#include "assistant.h"
#include <set>
#include <queue>
using namespace std;
int mem[200006];
void Assist(unsigned char *a, int n, int k, int r) {
queue<int> v;
set<int> s;
for (int i = 0; i < k; i++) mem[i] = i;
for (int i = 0; i < n + k; i++) if (a[i]) v.push(i), printf("%d ", i);
puts("");
for (int i = 0; i < k; i++) s.insert(i);
for (int i = 0; i < n; i++) {
int c = GetRequest();
mem[i + k] = c;
if (!s.count(c)) {
auto it = s.find(mem[v.front()]); v.pop();
s.erase(it);
PutBack(*it);
s.insert(c);
}
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:12:58: error: 'printf' was not declared in this scope
12 | for (int i = 0; i < n + k; i++) if (a[i]) v.push(i), printf("%d ", i);
| ^~~~~~
assistant.cpp:4:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
3 | #include <queue>
+++ |+#include <cstdio>
4 | using namespace std;
assistant.cpp:13:5: error: 'puts' was not declared in this scope
13 | puts("");
| ^~~~