#include <bits/stdc++.h>
#include "advisor.h"
template <class T> using Vec = std::vector<T>;
void ComputeAdvice(int *C, int N, int K, int M) {
Vec<std::queue<int>> appear(N);
for (int i = 0; i < N; ++i) {
appear[C[i]].push(i);
}
for (int i = 0; i < N; ++i) {
appear[i].push(N);
}
std::set<std::pair<int, int>> heap;
Vec<int> when(N, -2);
for (int i = 0; i < K; ++i) {
heap.emplace(appear[i].front(), i);
when[i] = -1;
}
Vec<char> send(N + K);
for (int i = 0; i < N; ++i) {
if (when[C[i]] == -2) {
assert(!heap.empty());
const int k = heap.rbegin() -> second;
heap.erase(std::prev(heap.end()));
if (when[k] == -1) {
send[k] = true;
} else {
send[K + when[k]] = true;
}
when[k] = -2;
} else {
heap.erase(std::make_pair(appear[C[i]].front(), i));
}
appear[C[i]].pop();
heap.emplace(appear[C[i]].front(), i);
when[C[i]] = i;
}
for (int i = 0; i < N; ++i) {
if (when[i] != -2) {
if (when[i] == -1) {
send[i] = true;
} else {
send[K + when[i]] = true;
}
}
}
for (const auto x : send) {
WriteAdvice(x);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
template <class T> using Vec = std::vector<T>;
void Assist(unsigned char *A, int N, int K, int R) {
Vec<char> has(N);
std::queue<int> dispose;
for (int i = 0; i < K; ++i) {
has[i] = true;
if (A[i]) {
dispose.push(i);
}
}
for (int i = 0; i < N; ++i) {
const int k = GetRequest();
if (!has[k]) {
assert(!dispose.empty());
PutBack(dispose.front());
has[dispose.front()] = false;
dispose.pop();
has[k] = true;
}
if (A[K + i]) {
dispose.push(k);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
488 KB |
Output is correct |
2 |
Incorrect |
1 ms |
616 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
7868 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
157 ms |
60088 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
3504 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
205 ms |
74260 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
192 ms |
74400 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
195 ms |
74632 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
215 ms |
74612 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
206 ms |
74684 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
192 ms |
74776 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
245 ms |
74552 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
208 ms |
74564 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
225 ms |
74644 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
173 ms |
73148 KB |
Error - Putting back a color that is not on the scaffold |