#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()
const int MX = 3e5;
queue<int> nxt[MX];
void ComputeAdvice(int *C, int N, int K, int M) {
vi shelf;
RE(i,N) nxt[C[i]].push(i);
RE(i,N) nxt[C[i]].push(N);
vi ans; ans.assign(K+N,0);
set<int> onShelf;
priority_queue<ii> pq;
map<int, int> last;
RE(i,K) {
onShelf.insert(i);
pq.push({nxt[i].front(), i});
last[i] = i;
}
RE(i,N) {
nxt[C[i]].pop();
last[C[i]] = K+i;
if(onShelf.count(C[i])) continue;
ii p = pq.top(); pq.pop();
ans[last[p.second]] = 1;
pq.push({nxt[C[i]].front(), C[i]});
}
for(int i:ans) WriteAdvice(i);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()
void Assist(unsigned char *A, int N, int K, int R) {
set<int> onShelf;
queue<int> rem;
RE(i,K) {
onShelf.insert(i);
if(A[i]) rem.push(i);
}
RE(i,N) {
int req = GetRequest();
if(!onShelf.count(req)) {
PutBack(rem.front());
onShelf.erase(rem.front()); rem.pop();
onShelf.insert(req);
}
if(A[K+i]) rem.push(req);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
135 ms |
404464 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
153 ms |
406000 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
297 ms |
415000 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
141 ms |
405232 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
332 ms |
416856 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Runtime error |
337 ms |
417232 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
3 |
Runtime error |
345 ms |
417800 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
4 |
Runtime error |
345 ms |
417664 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
5 |
Runtime error |
354 ms |
417920 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
6 |
Runtime error |
349 ms |
417664 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
7 |
Runtime error |
349 ms |
417664 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
8 |
Runtime error |
336 ms |
417672 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
9 |
Runtime error |
333 ms |
417672 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
10 |
Runtime error |
354 ms |
419976 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |