#include "advisor.h"
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int n,k,m,bit;
int c[111111];
int cnt[111111],pos[111111],col[111111];
vector<int> era;
void wri(int num){
for(int i=0;i<bit;i++){
if(num&(1<<i)) WriteAdvice(1);
else WriteAdvice(0);
}
}
void ComputeAdvice(int *C,int N,int K,int M){
n=N; k=K; m=M;
for(int i=0;i<n;i++) c[i]=C[i];
for(;k>(1<<bit);bit++);
//printf("%d\n",bit);
for(int i=0;i<n;i++) cnt[c[i]]++;
for(int i=0;i<k;i++) pos[i]=i;
for(int i=k;i<n;i++) pos[i]=-1;
for(int i=0;i<n;i++){
if(pos[i]<0) wri(0);
else{
for(int j=0;j<bit;j++){
if(era.empty()){
pos[c[i]]=1;
pos[col[1]]=-1;
col[1]=c[i];
wri(1);
}
else{
int eco=era.back(); era.pop_back();
pos[c[i]]=pos[eco];
pos[eco]=-1;
col[pos[c[i]]]=c[i];
wri(pos[c[i]]);
}
}
}
cnt[c[i]]--;
if(!cnt[c[i]]) era.push_back(c[i]);
}
}
#include "assistant.h"
#include <stdio.h>
int nn,kk,rr,bitt,poss;
int a[111111],coll[111111];
int read_(){
int num=0;
for(int i=0;i<bitt;i++) num+=a[poss+i]*(1<<i);
poss+=bitt;
return num;
}
void Assist(unsigned char *A, int N, int K, int R) {
nn=N; kk=K; rr=R;
for(int i=0;i<nn;i++) a[i]=A[i];
for(;kk>(1<<bitt);bitt++);
for(int i=0;i<kk;i++) coll[i+1]=i;
for(int i=0;i<nn;i++){
int num=read_();
if(num){
PutBack(coll[num]);
coll[num]=GetRequest();
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
608 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
68 ms |
3128 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
6352 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
6352 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
7848 KB |
Error - advice is too long |
2 |
Incorrect |
27 ms |
7936 KB |
Error - advice is too long |
3 |
Incorrect |
30 ms |
7968 KB |
Error - advice is too long |
4 |
Incorrect |
27 ms |
7968 KB |
Error - advice is too long |
5 |
Incorrect |
36 ms |
7968 KB |
Error - advice is too long |
6 |
Incorrect |
27 ms |
7968 KB |
Error - advice is too long |
7 |
Incorrect |
27 ms |
7968 KB |
Error - advice is too long |
8 |
Incorrect |
28 ms |
7968 KB |
Error - advice is too long |
9 |
Incorrect |
29 ms |
7968 KB |
Error - advice is too long |
10 |
Incorrect |
26 ms |
7968 KB |
Error - advice is too long |