#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,k,nex[200005],p[200005],ex[200005],ans[200005];
void ComputeAdvice(int *C, int N, int K, int M) {
n=N,k=K;
for(int i=0;i<n;i++)p[i]=n,ex[i]=-1;
for(int i=n-1;i>=0;i--){
nex[i]=p[C[i]];
p[C[i]]=i;
}
priority_queue<P>d;
for(int i=0;i<k;i++)d.push(P(p[i],i)),ex[i]=i;
for(int i=0;i<n;i++){
int c=C[i];
if(ex[c]!=-1)ans[ex[c]]=1;
else{
int y;
while(1){
y=d.top().second;
d.pop();
if(ex[y]==-1)continue;
}
ex[y]=-1;
}
ex[c]=k+i;
d.push(P(nex[i],c));
}
for(int i=0;i<k+n;i++)WriteAdvice(ans[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
set<int>x,y;
void Assist(unsigned char *A, int N, int K, int R) {
for(int i=0;i<K;i++){
if(A[i]==0)x.insert(i);
else y.insert(i);
}
for(int i=K;i<N+K;i++){
int c=GetRequest();
if(y.find(c)!=y.end())y.erase(c);
else{
PutBack(*x.begin());
x.erase(x.begin());
}
if(A[i]==0)x.insert(c);
else y.insert(c);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2535 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2528 ms |
640 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2539 ms |
2432 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2546 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2541 ms |
2816 KB |
Time limit exceeded |
2 |
Execution timed out |
2523 ms |
2816 KB |
Time limit exceeded |
3 |
Execution timed out |
2558 ms |
2816 KB |
Time limit exceeded |
4 |
Execution timed out |
2560 ms |
2816 KB |
Time limit exceeded |
5 |
Execution timed out |
2552 ms |
2816 KB |
Time limit exceeded |
6 |
Execution timed out |
2552 ms |
2816 KB |
Time limit exceeded |
7 |
Execution timed out |
2570 ms |
2808 KB |
Time limit exceeded |
8 |
Execution timed out |
2570 ms |
2816 KB |
Time limit exceeded |
9 |
Execution timed out |
2570 ms |
2944 KB |
Time limit exceeded |
10 |
Execution timed out |
2558 ms |
2944 KB |
Time limit exceeded |