#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 20;
vector<int> pos[maxN];
int A[maxN * 2];
void ComputeAdvice(int *C, int N, int K, int M) {
int L = 1;
while ((1 << L) < K) {
L++;
}
for (int i = N - 1; i >= 0; i--) {
pos[C[i]].push_back(i);
}
set<pair<int, pair<int, int>>> S;
for (int i = 0; i < K; i++) {
S.emplace(pos[i].empty() ? N : 0, make_pair(i, i));
}
for (int i = 0; i < N; i++) {
if (S.begin()->first == i) {
S.erase(S.begin());
}
else {
A[prev(S.end())->second.second] = 1;
S.erase(prev(S.end()));
}
S.emplace(pos[C[i]].empty() ? N : 0, make_pair(C[i], K + i));
}
for (int i = 0; i < K + N; i++) {
WriteAdvice(A[i]);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int maxK = 1e5 + 20;
int flag[maxK];
void Assist(unsigned char *A, int N, int K, int R) {
set<int> free;
set<int> S;
for (int i = 0; i < K; i++) {
if (A[i] == 1) {
free.insert(i);
}
S.insert(i);
}
for (int i = 0; i < N; i++) {
int X = GetRequest();
if (S.find(X) == S.end()) {
int Y = *free.begin();
PutBack(Y);
free.erase(Y);
S.erase(Y);
S.insert(X);
}
if (flag[X] == 0 && A[K + i] == 1) {
free.insert(X);
}
if (flag[X] == 1 && A[K + i] == 0) {
free.erase(X);
}
flag[X] = A[K + i];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2944 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2956 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
3932 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 |
77 ms |
10072 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 |
5 ms |
3232 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
88 ms |
11292 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
92 ms |
11620 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
97 ms |
11944 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
110 ms |
11980 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
98 ms |
12096 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
96 ms |
12048 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
99 ms |
11928 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
100 ms |
12112 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
101 ms |
12084 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
92 ms |
12912 KB |
Output isn't correct - not an optimal way |