#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
bitset<500100>onf;
void ComputeAdvice(int *C, int N, int K, int M) {
vector<int>nxt(N),lst(N,N),plat(K),dead(N+K,N);
iota(plat.begin(),plat.end(),0);
C[N]=N+5;
for(int i=N;i--;)
nxt[i]=lst[C[i]],
lst[C[i]]=i;
set<pair<int,int>> st;
for(auto i:plat)onf[i]=1,
st.insert({lst[i],i+N});
int df=log2(2*K-1);
for(int i=0;i<N;i++){
if(onf[C[i]]){
auto [x,y]=*st.lower_bound({i,0});
st.erase({x,y});
st.insert({nxt[i],y});
continue;
}
onf[C[i]]=1;
auto[x,y]=*--st.end();
dead[y]=i;
st.erase({x,y});
st.insert({nxt[i],i});
onf[C[x]]=0;
}
for(int i=0;i<K;i++)
nxt.push_back(lst[i]);
for(int i=0;i<N+K;i++)
WriteAdvice(dead[i]<nxt[i]);
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
bitset<500100>on;
void Assist(unsigned char *A, int N, int K, int R) {
set<int>passive;
for(int i=0;i<K;on[i]=1,i++)
if(A[N+i])
passive.insert(i);
for(int i=0;i<N;i++){
int x=GetRequest();
if(on[x]) { if(A[i])
passive.insert(x);
continue;
}
assert(passive.size());
int die=*passive.begin();
PutBack(die);
on[die]=0;on[x]=1;
passive.erase(die);
if(A[i])passive.insert(x);
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:15:9: warning: unused variable 'df' [-Wunused-variable]
15 | int df=log2(2*K-1);
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
784 KB |
Output is correct |
2 |
Runtime error |
2 ms |
1036 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
1680 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
66 ms |
6688 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
63 ms |
7764 KB |
Execution killed with signal 6 |
2 |
Runtime error |
85 ms |
7972 KB |
Execution killed with signal 6 |
3 |
Runtime error |
102 ms |
8120 KB |
Execution killed with signal 6 |
4 |
Runtime error |
60 ms |
8508 KB |
Execution killed with signal 6 |
5 |
Runtime error |
72 ms |
8252 KB |
Execution killed with signal 6 |
6 |
Runtime error |
78 ms |
8296 KB |
Execution killed with signal 6 |
7 |
Runtime error |
73 ms |
8248 KB |
Execution killed with signal 6 |
8 |
Runtime error |
68 ms |
8320 KB |
Execution killed with signal 6 |
9 |
Runtime error |
93 ms |
8336 KB |
Execution killed with signal 6 |
10 |
Runtime error |
56 ms |
7500 KB |
Execution killed with signal 6 |