#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
int b[100141],i,j,*ans;
priority_queue<pair<int,int>>pq;
deque<int>t[100141];
void ComputeAdvice(int *c, int n, int k, int m){
ans=(int*) malloc(n*sizeof(int));
for(i=0;i<n;i++)
t[c[i]].push_back(i);
for(i=0;i<n;i++)
t[i].push_back(999999);
for(i=0;i<k;i++)
{
b[i]=1;
pq.push({t[i][0],i});
}
for(i=0;i<n;i++)
{
t[c[i]].pop_front();
if(b[c[i]])
ans[i]=-1;
else
{
while(b[pq.top().second]==0)
pq.pop();
ans[i]=pq.top().second;
b[pq.top().second]=0;
b[c[i]]=1;
pq.pop();
}
pq.push({t[c[i]][0],c[i]});
}
}
#include "assistant.h"
extern int *ans;
void Assist(unsigned char *A, int n, int K, int R) {
for(int i=0;i<n;i++)
{
GetRequest();
if(ans[i]!=-1)
PutBack(ans[i]);
}
}
Compilation message
/tmp/cctBwhg9.o: In function `Assist(unsigned char*, int, int, int)':
assistant.cpp:(.text+0x28): undefined reference to `ans'
collect2: error: ld returned 1 exit status