#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int n, int k, int M) {
vector<int> l[n];
for (int i = 0; i < k; i++) l[i].push_back(i);
for (int i = 0; i < n; i++) l[C[i]].push_back(k + i);
for (int i = 0; i < n; i++) l[i].push_back(n + k + 100);
set<pair<int, int>> cur;
set<int> in;
auto to = [&](int i, int j) {
return *upper_bound(l[i].begin(), l[i].end(), j);
};
auto from = [&](int i, int j) {
auto it = lower_bound(l[i].begin(), l[i].end(), j);
return *(--it);
};
for (int i = 0; i < k; i++) cur.insert({-to(i, i), i}), in.insert(i);
vector<int> to_remove(n + k);
for (int i = 0; i < n; i++) {
if (in.find(C[i]) != in.end()) continue;
auto [idx, rem] = *cur.begin();
idx *= -1;
to_remove[from(rem, idx)] = 1;
cur.erase(cur.begin());
in.erase(rem);
cur.insert({-to(C[i], k + i), C[i]});
in.insert(C[i]);
}
for (int i : to_remove) WriteAdvice(i);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int n, int k, int R) {
vector<int> q;
set<int> s;
for (int i = 0; i < k; i++) {
if (A[i]) q.push_back(i);
s.insert(i);
}
for (int i = 0; i < n; i++) {
int req = GetRequest();
if (s.find(req) != s.end()) {
if (A[k + i]) q.push_back(req);
continue;
}
PutBack(q.back());
s.erase(q.back());
q.pop_back();
s.insert(req);
if (A[k + i]) q.push_back(req);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
508 KB |
Output is correct |
2 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1744 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
120 ms |
9892 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1048 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
159 ms |
11572 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
152 ms |
11888 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
177 ms |
12436 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
156 ms |
12412 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
162 ms |
12508 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
199 ms |
12316 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
160 ms |
12492 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
167 ms |
12428 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
160 ms |
12356 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
146 ms |
12268 KB |
Output is correct - 125000 bits used |