#include "advisor.h"
#include <bits/stdc++.h>
#define R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
unordered_map<int, vector<int>> mpa;
R(N) {
int a = C[i];
mpa[a].push_back(i);
}
unordered_set<int> val;
R(K) {
val.insert(i);
}
vector<int> nxt(N, -1);
priority_queue<ii> que;
R(K) {
if (!mpa[i].size()) {
que.push({INT_MAX, i});
nxt[i] = INT_MAX;
}
else {
que.push({mpa[i][0], i});
nxt[i] = mpa[i][0];
}
}
bool init[K] {};
bool rem[N] {};
vector<int> last(N, -1);
R(N) {
int a = C[i];
last[a] = i;
if (!val.count(a)) {
while (nxt[que.top().second] != que.top().first) {
que.pop();
}
auto b = que.top();
que.pop();
int c = b.second;
if (last[c] == -1) init[c] = true;
else rem[last[c]] = true;
}
auto it = upper_bound(mpa[a].begin(), mpa[a].end(), i);
if (it == mpa[a].end()) {
que.push({INT_MAX, a});
nxt[a] = INT_MAX;
}
else {
que.push({*it, a});
nxt[a] = *it;
}
}
R(K) {
if (init[i]) WriteAdvice(1);
else WriteAdvice(0);
}
R(N) {
if (rem[i]) WriteAdvice(1);
else WriteAdvice(0);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#define R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
queue<int> rem;
set<int> val;
R(K) {
cerr << "A " << (int)(A[i]) << endl;
}
cerr << "N\n";
R(N) {
cerr << "A " << (int)(A[K + i]) << endl;
}
R(K) {
val.insert(i);
if (A[i]) rem.push(i);
}
R(N) {
int a = GetRequest();
if (!val.count(a)) {
val.insert(a);
int b = rem.front();
PutBack(b);
val.erase(b);
rem.pop();
}
if (A[K + i]) rem.push(a);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
568 KB |
Output is correct |
2 |
Incorrect |
1 ms |
508 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
1740 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
516 ms |
10452 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
1132 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
594 ms |
12220 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
706 ms |
12564 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
706 ms |
12920 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
698 ms |
12996 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
722 ms |
12980 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
705 ms |
13000 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
715 ms |
13008 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
642 ms |
12924 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
668 ms |
12916 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
623 ms |
16156 KB |
Output is correct - 125000 bits used |