#include <iostream>
#include <algorithm>
#include "advisor.h"
using namespace std;
long long int maxlen,ans[1000005],k,map[1000005],in[1000005],t[1000005],p[1000005];
struct node{
long long int road,id;
}now[1000005];
struct cmp{
bool operator()(const node &a,const node &b)
{
return a.road<b.road;
}
};
void find(long long int x)
{
for(int i=1;i<=maxlen;i++)
{
char tmp;
if(x%2==0)tmp=0;
else tmp=1;
WriteAdvice(tmp);
//cout<<x%2<<" ";
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++)now[i].road=99999999999999999;
for(int i=0;i<N;i++)
{
map[i]=now[C[i]].road;
now[C[i]].road=i;
}
for(int i=0;i<N;i++)p[i]=-1;
for(int i=0;i<K;i++)
{
t[i]=i;
now[i].id=i;
p[i]=i;
push_heap(now,now+i+1,cmp());
}
//for(int i=0;i<K;i++)cout<<now[i].id<<" ";
//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].id];
find(p[C[i]]);
p[now[K-1].id]=-1;
now[C[i]].road=map[now[C[i]].road];
now[K-1].id=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];
//for(int i=0;i<R;i++)cout<<A[i]<<endl;
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;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
864 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
2060 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
221 ms |
13336 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1096 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
275 ms |
16440 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
260 ms |
16368 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
247 ms |
16112 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
263 ms |
16112 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
265 ms |
16112 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
272 ms |
16112 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
255 ms |
16112 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
265 ms |
16112 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
266 ms |
16112 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
271 ms |
16112 KB |
Output isn't correct - not an optimal way |