#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[1010101],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);
}
}
}
#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[1010101],isi[101010];
ll y[1010101];
ll ada[1010101];
ll las[1010101];
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/ccq2C1ZM.o: In function `main':
advisor_grader.cpp:(.text.startup+0xbd): undefined reference to `ComputeAdvice(int*, int, int, int)'
/tmp/ccxT1nDD.o: In function `Assist(unsigned char*, int, int, int)':
advisor.cpp:(.text+0x27d): undefined reference to `GetRequest()'
advisor.cpp:(.text+0x426): undefined reference to `PutBack(int)'
collect2: error: ld returned 1 exit status