#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define N 200100
int n, res[N], used[N], nxt[N], last[N];
void ComputeAdvice(int *C, int n, int k, int m) {
priority_queue<pair<int,int>> q;
for(int i = 0; i < n; i++)
last[i] = n, used[i] = -1;
for(int i = n; i--;)
nxt[i] = last[C[i]], last[C[i]] = i;
for(int i = 0; i < k; i++)
q.push({last[i], used[i] = i});
for(int i = 0; i < n; i++){
if(used[C[i]]+1) {
res[used[C[i]]] = 1;
} else {
used[q.top().second] = -1;
q.pop();
}
used[C[i]] = k+i;
q.push({nxt[i], C[i]});
}
for(int i = 0; i < n+k; i++)
WriteAdvice(res[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int n, int k, int r) {
set<int> y;
priority_queue<int, vector<int>, greater<int>> q;
for(int i=0;i<k;i++){
if(A[i])
y.insert(i);
else
q.push(i);
}
for(int i=k;i<n+k;i++){
int c = GetRequest();
if(y.find(c) != y.end()){
y.erase(c);
} else {
PutBack(q.top());
q.pop();
}
if(A[i])
y.insert(c);
else
q.push(c);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
516 KB |
Output is correct |
2 |
Correct |
1 ms |
524 KB |
Output is correct |
3 |
Correct |
2 ms |
784 KB |
Output is correct |
4 |
Correct |
2 ms |
668 KB |
Output is correct |
5 |
Correct |
2 ms |
676 KB |
Output is correct |
6 |
Correct |
3 ms |
812 KB |
Output is correct |
7 |
Correct |
4 ms |
940 KB |
Output is correct |
8 |
Correct |
4 ms |
940 KB |
Output is correct |
9 |
Correct |
4 ms |
932 KB |
Output is correct |
10 |
Correct |
4 ms |
944 KB |
Output is correct |
11 |
Correct |
4 ms |
936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1364 KB |
Output is correct |
2 |
Correct |
33 ms |
3176 KB |
Output is correct |
3 |
Correct |
75 ms |
6848 KB |
Output is correct |
4 |
Correct |
43 ms |
4948 KB |
Output is correct |
5 |
Correct |
49 ms |
4948 KB |
Output is correct |
6 |
Correct |
60 ms |
5184 KB |
Output is correct |
7 |
Correct |
74 ms |
6204 KB |
Output is correct |
8 |
Correct |
54 ms |
5548 KB |
Output is correct |
9 |
Correct |
49 ms |
4860 KB |
Output is correct |
10 |
Correct |
77 ms |
6580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
5164 KB |
Output is correct |
2 |
Correct |
74 ms |
6292 KB |
Output is correct |
3 |
Correct |
81 ms |
6300 KB |
Output is correct |
4 |
Correct |
78 ms |
6556 KB |
Output is correct |
5 |
Correct |
73 ms |
6068 KB |
Output is correct |
6 |
Correct |
75 ms |
6356 KB |
Output is correct |
7 |
Correct |
76 ms |
6364 KB |
Output is correct |
8 |
Correct |
66 ms |
6084 KB |
Output is correct |
9 |
Correct |
76 ms |
6288 KB |
Output is correct |
10 |
Correct |
75 ms |
6308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
928 KB |
Output is correct |
2 |
Correct |
4 ms |
932 KB |
Output is correct |
3 |
Correct |
4 ms |
812 KB |
Output is correct |
4 |
Correct |
3 ms |
812 KB |
Output is correct |
5 |
Correct |
3 ms |
804 KB |
Output is correct |
6 |
Correct |
3 ms |
804 KB |
Output is correct |
7 |
Correct |
4 ms |
936 KB |
Output is correct |
8 |
Correct |
5 ms |
932 KB |
Output is correct |
9 |
Correct |
4 ms |
932 KB |
Output is correct |
10 |
Correct |
4 ms |
1200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
6244 KB |
Output is correct - 120000 bits used |
2 |
Correct |
80 ms |
6428 KB |
Output is correct - 122000 bits used |
3 |
Correct |
74 ms |
6412 KB |
Output is correct - 125000 bits used |
4 |
Correct |
78 ms |
6376 KB |
Output is correct - 125000 bits used |
5 |
Correct |
82 ms |
6452 KB |
Output is correct - 125000 bits used |
6 |
Correct |
74 ms |
6372 KB |
Output is correct - 125000 bits used |
7 |
Correct |
78 ms |
6488 KB |
Output is correct - 124828 bits used |
8 |
Correct |
74 ms |
6372 KB |
Output is correct - 124910 bits used |
9 |
Correct |
75 ms |
6376 KB |
Output is correct - 125000 bits used |
10 |
Correct |
65 ms |
6168 KB |
Output is correct - 125000 bits used |