#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=K;i<N+K;++i)
{
int u=GetRequest();
if(!in[u])
{
if(!gg.size()) throw "GG";
int w=gg.back();
gg.pop_back();
PutBack(w);
in[w]=0;
}
in[u]=1;
if(A[u]) gg.pb(u);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
760 KB |
Output is correct |
2 |
Runtime error |
6 ms |
1008 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
1728 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
61 ms |
7136 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
1164 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
73 ms |
8928 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
74 ms |
8928 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
77 ms |
8872 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
74 ms |
8672 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
75 ms |
8928 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
77 ms |
8768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
75 ms |
8672 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
77 ms |
8928 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
78 ms |
9072 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
76 ms |
8176 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |