#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
const int maxn = 200005;
int f1[maxn], f2[maxn], f3[maxn];
bool del[maxn];
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i = 0; i < N; ++i) f1[i] = N;
for (int i = N - 1; i >= 0; --i) {
f2[i] = f1[C[i]], f1[C[i]] = i;
}
for (int i = 0; i < K; ++i) f2[i + N] = f1[i];
set< pair<int, int> > s;
for (int i = 0; i < N; ++i) f3[i] = -1;
for (int i = 0; i < K; ++i) {
f3[i] = i + N, s.insert({f2[i + N], i + N});
}
for (int i = 0; i < N; ++i) {
int &tmp = f3[C[i]];
set< pair<int, int> > :: iterator it;
if (tmp == -1) {
it = --s.end();
int p = it -> second;
del[p] = 1;
if (p > N) f3[p - N] = -1;
else f3[C[p]] = -1;
}
else {
it = s.find({f2[tmp], tmp});
assert(it != s.end());
}
s.erase(it);
tmp = i;
s.insert({f2[i], i});
}
for (auto i : s) del[i.second] = 1;
for (int i = 0; i < N + K; ++i) WriteAdvice(del[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
set<int> s1, s2;
for (int i = 0; i < K; ++i) {
s1.insert(i);
if (A[i + N]) s2.insert(i);
}
for (int i = 0; i < N; ++i) {
int tmp = GetRequest();
if (s1.find(tmp) == s1.end()) {
int p = *s2.begin();
assert(s1.find(p) != s1.end());
s1.erase(p), s2.erase(p);
PutBack(p);
s1.insert(tmp);
}
if (A[i]) s2.insert(i);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
740 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
19 ms |
2216 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
136 ms |
10224 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
11056 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
170 ms |
12428 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
177 ms |
16656 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
197 ms |
18416 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
196 ms |
19736 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
167 ms |
21008 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
221 ms |
22144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
180 ms |
23312 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
210 ms |
24464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
157 ms |
25880 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
168 ms |
26792 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |