#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) {
for (int i = N - 1; i >= 0; i--) {
pos[C[i]].push_back(i);
}
set<pair<int, int>> S;
for (int i = 0; i < K; i++) {
S.emplace(pos[i].empty() ? N : 0, i);
}
for (int i = 0; i < N; i++) {
if (S.begin()->first == i) {
S.erase(S.begin());
}
else {
A[prev(S.end())->second] = 1;
S.erase(prev(S.end()));
}
S.emplace(pos[C[i]].empty() ? N : 0, 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 |
Incorrect |
1 ms |
2956 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
3756 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 |
76 ms |
9488 KB |
Output isn't correct - not an optimal way |
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 |
96 ms |
10668 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
91 ms |
10892 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
97 ms |
11296 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
96 ms |
11248 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
93 ms |
11296 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
100 ms |
11504 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
95 ms |
11452 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
94 ms |
11296 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
99 ms |
11424 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
100 ms |
13152 KB |
Output isn't correct - not an optimal way |