#include <iostream>
#include <algorithm>
#include "advisor.h"
using namespace std;
long long int maxlen,ans[1000005],now[1000005],k,road[1000005],map[1000005],in[1000005],t[1000005],p[1000005];
struct cmp{
bool operator()(const int a,const int b)
{
return road[a]>road[b];
}
};
void find(int x)
{
for(int i=1;i<=maxlen;i++)
{
if(x%2==0)WriteAdvice('0');
else WriteAdvice('1');
x/=2;
}
return ;
}
void ComputeAdvice(int *C, int N, int K, int M) {
k=K;
long long int x=1;
while(x<k)
{
x*=2;
maxlen++;
}
for(int i=0;i<N;i++)
{
map[i]=road[C[i]];
road[C[i]]=i;
}
for(int i=0;i<N;i++)p[i]=-1;
for(int i=0;i<K;i++)
{
t[i]=i;
now[i]=i;
p[i]=i;
push_heap(now,now+i,cmp());
}
for(int i=0;i<K;i++)cout<<now[i]<<" ";
cout<<endl;
for(int i=0;i<N;i++)
{
if(p[C[i]]!=-1)continue;
else
{
pop_heap(now,now+K,cmp());
p[C[i]]=p[now[K-1]];
find(p[C[i]]);
p[now[K-1]]=-1;
road[C[i]]=map[road[C[i]]];
now[K-1]=C[i];
push_heap(now,now+K,cmp());
}
}
}
#include "assistant.h"
#include <iostream>
using namespace std;
long long int a[1000005],pp,malen;
int find()
{
long long int tmp=0,x=1;
for(int i=pp+1;i<=pp+malen;i++)
{
if(a[i]=='1')tmp+=x;
x*=2;
}
return tmp;
}
void Assist(unsigned char *A, int N, int K, int R) {
long long int now[100005],k,p[100005];
k=K;
long long int x=1;
while(x<k)
{
x*=2;
malen++;
}
for(int i=0;i<N;i++)p[i]=-1;
for(int i=0;i<k;i++)
{
now[i]=i;
p[i]=i;
}
for(int i=0;i<N;i++)
{
long long int tmp=GetRequest();
if(p[tmp]!=-1)
{
continue;
}
long long int temp=find();
PutBack(now[temp]);
p[now[temp]]=-1;
now[temp]=tmp;
p[tmp]=temp;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
904 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1536 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
6912 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1072 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
8192 KB |
Error - Invalid Access |
2 |
Incorrect |
26 ms |
8432 KB |
Error - Invalid Access |
3 |
Incorrect |
28 ms |
8432 KB |
Error - Invalid Access |
4 |
Incorrect |
30 ms |
8432 KB |
Error - Invalid Access |
5 |
Incorrect |
32 ms |
8432 KB |
Error - Invalid Access |
6 |
Incorrect |
20 ms |
8448 KB |
Error - Invalid Access |
7 |
Incorrect |
20 ms |
8432 KB |
Error - Invalid Access |
8 |
Incorrect |
22 ms |
8432 KB |
Error - Invalid Access |
9 |
Incorrect |
29 ms |
8432 KB |
Error - Invalid Access |
10 |
Incorrect |
28 ms |
8432 KB |
Error - Invalid Access |