#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 : pos[i].back(), 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 : pos[i].back(), 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 |
Runtime error |
4 ms |
5076 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
5844 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
18 ms |
10824 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
5496 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
21 ms |
11884 KB |
Execution killed with signal 11 |
2 |
Runtime error |
21 ms |
12088 KB |
Execution killed with signal 11 |
3 |
Runtime error |
22 ms |
12320 KB |
Execution killed with signal 11 |
4 |
Runtime error |
21 ms |
12292 KB |
Execution killed with signal 11 |
5 |
Runtime error |
21 ms |
12372 KB |
Execution killed with signal 11 |
6 |
Runtime error |
21 ms |
12372 KB |
Execution killed with signal 11 |
7 |
Runtime error |
21 ms |
12388 KB |
Execution killed with signal 11 |
8 |
Runtime error |
21 ms |
12440 KB |
Execution killed with signal 11 |
9 |
Runtime error |
21 ms |
12372 KB |
Execution killed with signal 11 |
10 |
Runtime error |
23 ms |
14548 KB |
Execution killed with signal 11 |