#include "advisor.h"
#include <bits/stdc++.h>
#define R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
vector<int> nxt(N, INT_MAX);
vector<int> val(N);
for (int i = N - 1; i >= 0; --i) {
int a = C[i];
val[i] = nxt[a];
nxt[a] = i;
}
vector<bool> init(K);
vector<bool> rem(N);
priority_queue<ii> que;
R(K) {
que.push({nxt[i], i});
}
vector<bool> has(N);
vector<int> last(N, -1);
R(K) {
has[i] = true;
}
R(N) {
int a = C[i];
if (!has[a]) {
auto b = que.top();
que.pop();
if (last[b.second] == -1) init[b.second] = true;
else rem[last[b.second]] = true;
}
last[a] = i;
que.push({val[i], a});
}
R(K) {
if (init[i]) WriteAdvice(1);
else WriteAdvice(0);
}
R(N) {
if (rem[i]) WriteAdvice(1);
else WriteAdvice(0);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#define R(a) for (int i = 0; i < a; ++i)
#define ii pair<int, int>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
queue<int> rem;
set<int> val;
R(K) {
cerr << "A " << (int)(A[i]) << endl;
}
cerr << "N\n";
R(N) {
cerr << "A " << (int)(A[K + i]) << endl;
}
R(K) {
val.insert(i);
if (A[i]) rem.push(i);
}
R(N) {
int a = GetRequest();
if (!val.count(a)) {
val.insert(a);
int b = rem.front();
PutBack(b);
val.erase(b);
rem.pop();
}
if (A[K + i]) rem.push(a);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
508 KB |
Output is correct |
2 |
Incorrect |
2 ms |
508 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
52 ms |
1108 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
453 ms |
5000 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
716 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
533 ms |
5688 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
509 ms |
5868 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
569 ms |
6128 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
549 ms |
6076 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
540 ms |
6124 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
547 ms |
5928 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
549 ms |
6224 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
576 ms |
5928 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
540 ms |
5928 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
567 ms |
5828 KB |
Output is correct - 125000 bits used |