#include "assistant.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll z[2010101],isi[101010];
ll y[101010];
ll ada[101010];
ll las[101010];
ll lok[101010];
void Assist(unsigned char *A, int N, int K, int R)
{
priority_queue<pair<ll,ll> > pq;
ll i,j;
ll x=ceil(log(N)/log(2));
for (i = 0; i < R; i++)
{
if(A[i])
{
// cout<<i<<"YA\n";
z[i]=1;
}
//cout<<i<<"___"<<A[i]<<"\n";
//z[(ll)A[i]]=1;
}
for (i = 0; i < N; i++)
for(j=0;j<x;j++)
isi[i]+=z[i*x+j]*(1<<j);
for(i=0;i<N;i++)
{
// cout<<i<<" "<<isi[i]<<"\n";
las[i]=N;
}
for(i=N-1;i>=0;i--)
{
y[i]=las[isi[i]];
las[isi[i]]=i;
}
for(i=0;i<K;i++)
{
pq.push(mp(las[i],i));
ada[i]=1;
lok[i]=i;
}
for (i = 0; i < N; i++)
{
int req = GetRequest();
if(ada[req])
{
las[isi[i]]=y[i];
pq.push(mp(las[isi[i]],isi[i]));
}
else
{
while(!pq.empty()&&ada[pq.top().se]==0)pq.pop();
while(!pq.empty()&&las[pq.top().se]!=pq.top().fi)pq.pop();
ada[req]=1;
ll tem=pq.top().se;
ll za=lok[tem];
lok[za]=req;
// cout<<i<<" "<<tem<<"_) \n";
pq.pop();
ada[tem]=0;
las[isi[i]]=y[i];
pq.push(mp(las[isi[i]],isi[i]));
//pq.push(mp(las[req],req));
PutBack(tem);
}
}
}
#include "assistant.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll z[2010101],isi[101010];
ll y[101010];
ll ada[101010];
ll las[101010];
void Assist(unsigned char *A, int N, int K, int R)
{
priority_queue<pair<ll,ll> > pq;
ll i,j;
ll x=ceil(log(N)/log(2));
for (i = 0; i < R; i++)
{
if(A[i])
{
// cout<<i<<"YA\n";
z[i]=1;
}
//cout<<i<<"___"<<A[i]<<"\n";
//z[(ll)A[i]]=1;
}
for (i = 0; i < N; i++)
for(j=0;j<x;j++)
isi[i]+=z[i*x+j]*(1<<j);
for(i=0;i<N;i++)
{
// cout<<i<<" "<<isi[i]<<"\n";
las[i]=N;
}
for(i=N-1;i>=0;i--)
{
y[i]=las[isi[i]];
las[isi[i]]=i;
}
for(i=0;i<K;i++)
pq.push(mp(las[i],i));
for(i=0;i<K;i++)
ada[i]=1;
for (i = 0; i < N; i++)
{
int req = GetRequest();
if(ada[req])
{
las[isi[i]]=y[i];
pq.push(mp(las[isi[i]],isi[i]));
}
else
{
while(!pq.empty()&&ada[pq.top().se]==0)pq.pop();
while(!pq.empty()&&las[pq.top().se]!=pq.top().fi)pq.pop();
ada[req]=1;
ll tem=pq.top().se;
// cout<<i<<" "<<tem<<"_) \n";
pq.pop();
ada[tem]=0;
las[isi[i]]=y[i];
pq.push(mp(las[isi[i]],isi[i]));
//pq.push(mp(las[req],req));
PutBack(tem);
}
}
}
Compilation message
/tmp/cc9WBmrR.o: In function `main':
advisor_grader.cpp:(.text.startup+0xbd): undefined reference to `ComputeAdvice(int*, int, int, int)'
/tmp/ccZ02dKz.o: In function `Assist(unsigned char*, int, int, int)':
advisor.cpp:(.text+0x275): undefined reference to `GetRequest()'
advisor.cpp:(.text+0x42e): undefined reference to `PutBack(int)'
collect2: error: ld returned 1 exit status