#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
void ComputeAdvice(int *C, int n, int k, int M) {
vector <int> last(n, n), nxt(n);
int i;
for(i = n - 1; i >= 0; i--) {
nxt[i] = last[C[i]];
last[C[i]] = i;
}
set < pair <int, int> > pq;
vector <int> pos(n, -1);
for(i = 0; i < k; i++) {
pq.insert({last[i], i});
pos[i] = i;
}
vector <unsigned char> sol(n + k, 0);
for(i = 0; i < n; i++) {
if(pos[C[i]] != -1) {
sol[pos[C[i]]] = 1;
pq.erase(pq.lower_bound({i, -1}));
}
else {
pos[prev(pq.end()) -> second] = -1;
pq.erase(prev(pq.end()));
}
pq.insert({nxt[i], i + k});
pos[C[i]] = i + k;
/*for(auto it : pq) {
cerr << it.first << " " << it.second << "\n";
}
cerr << "\n";*/
}
for(auto it : sol) {
WriteAdvice(it);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int n, int k, int R) {
set <int> col, bad;
int i;
/*cerr << n + k << "\n";
for(i = 0; i < n + k; i++) {
cerr << (int) A[i] << " ";
}*/
for(i = 0; i < k; i++) {
col.insert(i);
if(A[i] == 0) {
bad.insert(i);
}
}
for(i = k; i < n + k; i++) {
int cur = GetRequest();
if(col.count(cur) == 0) {
if(bad.size() == 0) {
while(1) {
}
}
PutBack(*bad.begin());
col.erase(*bad.begin());
bad.erase(bad.begin());
}
if(A[i] == 0) {
bad.insert(cur);
}
col.insert(cur);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
772 KB |
Output is correct |
2 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
1016 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
49 ms |
3300 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
732 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
58 ms |
3824 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
59 ms |
3852 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
62 ms |
3964 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Incorrect |
195 ms |
8100 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
194 ms |
8196 KB |
Output isn't correct - not an optimal way |
6 |
Runtime error |
67 ms |
4012 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Incorrect |
195 ms |
8208 KB |
Output isn't correct - not an optimal way |
8 |
Runtime error |
65 ms |
3716 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Incorrect |
194 ms |
8044 KB |
Output isn't correct - not an optimal way |
10 |
Runtime error |
52 ms |
3980 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |