#include "advisor.h"
#include<queue>
using namespace std;
priority_queue<int>q;
int a[100010],ch[100010],arr[100010],w,paint2[100010],dap[100010],pdap[25010];
void ComputeAdvice(int *C, int N, int K, int M)
{
int i,p;
for(i=N-1;i>=0;i--)
{
if(ch[C[i]]==0) a[i]=N;
else a[i]=ch[C[i]];
ch[C[i]]=i;
}
for(i=0;i<K;i++)
{
paint2[i]=1;
if(ch[i]==0) q.push(N);
else q.push(ch[i]);
arr[i]=-1;
}
for(i=0;i<=N-1;i++)
{
if(paint2[C[i]]==1)
{
arr[C[i]]=i; continue;
}
p=q.top();
if(p!=N)
{
if(arr[C[p]]==-1) pdap[C[p]]=1;
else dap[arr[C[p]]]=1;
}
paint2[q.top()]--; q.pop();
if(a[C[i]]==0){ q.push(N); paint2[N]++;}
else{q.push(a[C[i]]); paint2[a[C[i]]]++;}
arr[C[i]]=i;
}
for(i=0;i<N;i++)
{
dap[arr[C[i]]]=1;
}
for(i=0;i<K;i++)
{
WriteAdvice(pdap[i]);
}
for(i=0;i<N;i++)
{
WriteAdvice(dap[i]);
}
}
#include "assistant.h"
int paint[25010],request[100010],st[100010],top,ch2[100010],c;
void Assist(unsigned char *A, int N, int K, int R)
{
int i;
for(i=0;i<K;i++) paint[i]=A[i];
for(i=0;i<N;i++) request[i]=A[K+i];
for(i=0;i<K;i++)
{
if(paint[i]==1) st[++top]=i;
ch2[i]++;
}
for(i=0;i<N;i++)
{
c=GetRequest();
if(ch2[c]==1) continue;
PutBack(st[top]);
ch2[c]++;
ch2[st[top]]--;
st[top--]=0;
if(request[c]==1) st[++top]=c;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
608 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1336 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
79 ms |
6712 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6712 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
8032 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
75 ms |
8304 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
117 ms |
8464 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
91 ms |
8464 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
80 ms |
8560 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
91 ms |
8560 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
75 ms |
8560 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
77 ms |
8576 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
75 ms |
8576 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
83 ms |
8576 KB |
Output isn't correct - not an optimal way |