#include <bits/stdc++.h>
using namespace std;
#include "advisor.h"
#define pb push_back
const int N=100050;
int last[N],go[N];
bool in[N];
pair<int,pair<int,int>> l[N];
bool was[2*N];
void WriteAdvice(unsigned char);
void ComputeAdvice(int *C, int n, int k, int M)
{
priority_queue<pair<int,pair<int,int>>> pq,rq;
for(int i=0;i<n;i++) last[i]=n;
for(int i=n-1;i>=0;i--) go[i]=last[C[i]],last[C[i]]=i;
for(int i=0;i<k;i++)
{
pq.push({last[i],{i,i}});
in[i]=1;
l[i]={last[i],{i,i}};
}
for(int i=0;i<n;i++)
{
while(pq.size() && rq.size() && pq.top()==rq.top()) pq.pop(),rq.pop();
if(in[C[i]])
{
rq.push(l[C[i]]);
l[C[i]]={go[i],{C[i],i+k}};
pq.push(l[C[i]]);
}
else
{
was[pq.top().second.second]=1;
in[pq.top().second.first]=0;
rq.push(pq.top());
l[C[i]]={go[i],{C[i],i+k}};
pq.push(l[C[i]]);
in[C[i]]=1;
}
}
for(int i=0;i<n+k;i++) WriteAdvice((unsigned char)was[i]);
}
#include <bits/stdc++.h>
using namespace std;
#include "advisor.h"
#define pb push_back
const int N=100050;
int last[N],go[N];
bool in[N];
pair<int,pair<int,int>> l[N];
int was[2*N];
void ComputeAdvice(int *C, int n, int k, int M)
{
priority_queue<pair<int,pair<int,int>>> pq,rq;
for(int i=0;i<n;i++) last[i]=n;
for(int i=n-1;i>=0;i--) go[i]=last[C[i]],last[C[i]]=i;
for(int i=0;i<k;i++)
{
pq.push({last[i],{i,i}});
in[i]=1;
l[i]={last[i],{i,i}};
}
for(int i=0;i<n;i++)
{
while(pq.size() && rq.size() && pq.top()==rq.top()) pq.pop(),rq.pop();
if(in[C[i]])
{
rq.push(l[C[i]]);
l[C[i]]={go[i],{C[i],i+k}};
pq.push(l[C[i]]);
}
else
{
was[pq.top().second.second]=1;
in[pq.top().second.first]=0;
rq.push(pq.top());
l[C[i]]={go[i],{C[i],i+k}};
pq.push(l[C[i]]);
in[C[i]]=1;
}
}
for(int i=0;i<n+k;i++) WriteAdvice(was[i]);
}
Compilation message
/tmp/ccgcdgVt.o: In function `main':
assistant_grader.cpp:(.text.startup+0x1ed): undefined reference to `Assist(unsigned char*, int, int, int)'
/tmp/ccj3Bb9C.o: In function `ComputeAdvice(int*, int, int, int)':
assistant.cpp:(.text+0x6b1): undefined reference to `WriteAdvice(unsigned char)'
collect2: error: ld returned 1 exit status