#include "advisor.h"
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#include <stdio.h>
using namespace std;
int where[1000005];
int Next[1000005];
vector < int > when[100005];
map < int , int > how;
void ComputeAdvice(int *C, int N, int K, int M)
{
int t=0,now=1,xx,i,j;
while(now<K)
{
now*=2;
t++;
}
for(i=0;i<N;i++) when[C[i]].push_back(i);
for(i=0;i<N;i++) when[i].push_back(i+N);
for(i=0;i<N;i++) Next[i]=*upper_bound(when[C[i]].begin(),when[C[i]].end(),i);
for(i=0;i<K;i++)
{
where[i]=i;
how[when[i][0]]=i;
}
for(i=K;i<N;i++) where[i]=-1;
for(i=0;i<N;i++)
{
if(how.find(i)!=how.end()) how.erase(i);
if(where[C[i]]==-1)
{
xx=where[prev(how.end())->second];
for(j=0;j<t;j++)
{
if(xx&(1<<j)) WriteAdvice(1);
else WriteAdvice(0);
}
where[C[i]]=xx;
where[prev(how.end())->second]=-1;
how.erase(prev(how.end())->second);
}
how[Next[i]]=C[i];
}
}
#include "assistant.h"
int where2[1000005];
int what[1000005];
void Assist(unsigned char *A, int N, int K, int R) {
int t=0,now=1,xx=0,how,tt=0,i,j;
while(now<K)
{
now*=2;
t++;
}
for(i=0;i<K;i++)
{
where2[i]=i;
what[i]=i;
}
for(i=K;i<N;i++) where2[i]=-1;
for(i=0;i<N;i++)
{
how=GetRequest();
if(where2[how]==-1)
{
xx=0;
for(j=0;j<t;j++) xx+=A[j+tt]*(1<<j);
tt+=t;
PutBack(what[xx]);
where2[how]=xx;
where2[what[xx]]=-1;
what[xx]=how;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3244 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3228 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
4420 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
282 ms |
16760 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
3536 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
364 ms |
20196 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
366 ms |
20016 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
364 ms |
19896 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
348 ms |
19768 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
376 ms |
20060 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
337 ms |
19744 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
340 ms |
19904 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
345 ms |
19728 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
349 ms |
19740 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
344 ms |
21136 KB |
Error - Putting back a color that is not on the scaffold |