#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()));
}
pos[C[i]].pop_back();
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++) {
flag[i] = A[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];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2940 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2948 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
3668 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
91 ms |
9640 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
3240 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
112 ms |
10792 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
95 ms |
11048 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
93 ms |
11532 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
97 ms |
11432 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
122 ms |
11532 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
95 ms |
11532 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
95 ms |
11476 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
96 ms |
11532 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
94 ms |
11524 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
97 ms |
13148 KB |
Output isn't correct - not an optimal way |