#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define SZ 222222
typedef pair<int,int> pii;
#define fi first
#define se second
int d[SZ],e[SZ],f[SZ],ns[SZ],ts[SZ];
void ComputeAdvice(int *C,int N,int K,int M)
{
for(int i=0;i<N;++i) f[i]=-1,ts[i]=2e9;
for(int i=0;i<N+K;++i)
{
if(i<K) d[i]=i;
else d[i]=C[i-K];
}
for(int i=N+K-1;i>=0;--i)
ns[i]=ts[d[i]],ts[d[i]]=i;
priority_queue<pii> pq,eq;
for(int i=0;i<K;++i)
pq.push(pii(2e9+i,-1));
for(int i=0;i<N+K;++i)
{
while(pq.size()&&eq.size()&&pq.top()==eq.top())
pq.pop(),eq.pop();
int x=d[i];
if(~f[x])
eq.push(pii(i,f[x]));
else
{
auto w=pq.top(); pq.pop();
if(~w.se) e[w.se]=1,f[d[w.se]]=-1;
}
f[x]=i; pq.push(pii(ns[i],i));
}
for(int i=0;i<N+K;++i)
WriteAdvice(e[i]);
}
#include "assistant.h"
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define SZ 222222
typedef pair<int,int> pii;
#define pb push_back
#define fi first
#define se second
bool in[SZ];
void Assist(unsigned char *A, int N, int K, int R)
{
vector<int> gg;
for(int i=0;i<K;++i)
{
in[i]=1;
if(A[i]) gg.pb(i);
}
for(int i=N;i<N+K;++i)
{
int u=GetRequest();
if(in[u])
{
if(A[u]) gg.pb(u);
}
else
{
int w=gg.back();
gg.pop_back();
PutBack(w);
in[w]=0;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
764 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
1728 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
57 ms |
8160 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1264 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
71 ms |
10208 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Incorrect |
71 ms |
10256 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
69 ms |
9952 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
70 ms |
9944 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
71 ms |
9904 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
73 ms |
9952 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
72 ms |
9952 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
71 ms |
10040 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
73 ms |
9960 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
68 ms |
9256 KB |
Error - Putting back a color that is not on the scaffold |