#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<int> last(N, -1);
for (int i = 0; i < N; ++i) {
last[C[i]] = i;
}
for (int i = 0; i < K; ++i) {
WriteAdvice(last[i] == -1);
}
for (int i = 0; i < N; ++i) {
WriteAdvice(last[C[i]] == i);
}
}
#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<int> del;
std::set<int> has;
for (int i = 0; i < K; ++i) {
if (A[i]) {
del.push_back(i);
}
has.insert(i);
}
for (int i = 0; i < N; ++i) {
const auto k = GetRequest();
if (has.find(k) == has.end()) {
if (!del.empty()) {
const auto x = del.back();
del.pop_back();
PutBack(x);
has.erase(x);
}
else {
PutBack(*has.begin());
has.erase(has.begin());
}
has.insert(k);
}
if (A[K + i]) {
del.push_back(k);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
484 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
616 KB |
Output is correct |
4 |
Incorrect |
3 ms |
644 KB |
Output isn't correct - not an optimal way |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
1000 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
4808 KB |
Output is correct |
2 |
Correct |
101 ms |
5684 KB |
Output is correct |
3 |
Correct |
99 ms |
5680 KB |
Output is correct |
4 |
Correct |
103 ms |
5720 KB |
Output is correct |
5 |
Incorrect |
108 ms |
5636 KB |
Output isn't correct - not an optimal way |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
776 KB |
Output is correct |
2 |
Correct |
6 ms |
800 KB |
Output is correct |
3 |
Incorrect |
4 ms |
672 KB |
Output isn't correct - not an optimal way |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
104 ms |
5496 KB |
Output isn't correct - not an optimal way |
2 |
Correct |
109 ms |
5944 KB |
Output is correct - 122000 bits used |
3 |
Correct |
105 ms |
5812 KB |
Output is correct - 125000 bits used |
4 |
Correct |
107 ms |
5776 KB |
Output is correct - 125000 bits used |
5 |
Correct |
106 ms |
5780 KB |
Output is correct - 125000 bits used |
6 |
Correct |
117 ms |
5740 KB |
Output is correct - 125000 bits used |
7 |
Correct |
101 ms |
5704 KB |
Output is correct - 124828 bits used |
8 |
Correct |
106 ms |
5756 KB |
Output is correct - 124910 bits used |
9 |
Correct |
102 ms |
5812 KB |
Output is correct - 125000 bits used |
10 |
Incorrect |
109 ms |
5844 KB |
Output isn't correct - not an optimal way |