#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 20;
vector<int> pos[maxN];
void ComputeAdvice(int *C, int N, int K, int M) {
int L = 1;
while ((1 << L) < K) {
L++;
}
for (int i = N - 1; i >= 0; i--) {
pos[C[i]].push_back(i);
}
map<int, int> cur;
set<pair<int, int>> S;
for (int i = 0; i < K; i++) {
S.emplace(pos[i].empty() ? N : pos[i].back(), i);
cur[i] = i;
}
for (int i = 0; i < N; i++) {
int x = -1;
if (S.begin()->second == C[i]) {
x = cur[C[i]];
S.erase(S.begin());
}
else {
x = cur[prev(S.end())->second];
for (int j = 0; j < L; j++) {
WriteAdvice((x >> j) & 1);
}
S.erase(prev(S.end()));
}
cur[C[i]] = x;
pos[C[i]].pop_back();
S.emplace(pos[C[i]].empty() ? N : pos[C[i]].back(), C[i]);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int maxK = 1e5 + 20;
int colors[maxK];
void Assist(unsigned char *A, int N, int K, int R) {
int L = 1;
while ((1 << L) < K) {
L++;
}
set<int> S;
for (int i = 0; i < K; i++) {
colors[i] = i;
S.insert(i);
}
int pt = 0;
for (int i = 0; i < N; i++) {
int C = GetRequest();
if (S.find(C) != S.end()) {
continue;
}
int pos = 0;
for (int j = 0; j < L; j++) {
pos |= (A[pt + j] << j);
}
pt += L;
PutBack(colors[pos]);
colors[pos] = C;
S.erase(colors[pos]);
S.insert(C);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2952 KB |
Output is correct |
2 |
Correct |
1 ms |
2952 KB |
Output is correct |
3 |
Correct |
2 ms |
3216 KB |
Output is correct |
4 |
Incorrect |
4 ms |
2988 KB |
Error - Not putting back color when it is not on the scaffold |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
4592 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
186 ms |
16900 KB |
Output is correct |
2 |
Correct |
230 ms |
20352 KB |
Output is correct |
3 |
Correct |
253 ms |
20400 KB |
Output is correct |
4 |
Correct |
220 ms |
19388 KB |
Output is correct |
5 |
Incorrect |
205 ms |
15772 KB |
Error - Not putting back color when it is not on the scaffold |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
3252 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
227 ms |
20276 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Correct |
237 ms |
20396 KB |
Output is partially correct - 742095 bits used |
3 |
Correct |
275 ms |
20380 KB |
Output is partially correct - 712470 bits used |
4 |
Correct |
231 ms |
20320 KB |
Output is partially correct - 712005 bits used |
5 |
Correct |
234 ms |
20312 KB |
Output is partially correct - 710610 bits used |
6 |
Correct |
229 ms |
20376 KB |
Output is partially correct - 712155 bits used |
7 |
Correct |
249 ms |
20360 KB |
Output is partially correct - 711090 bits used |
8 |
Correct |
225 ms |
20352 KB |
Output is partially correct - 713340 bits used |
9 |
Correct |
229 ms |
20360 KB |
Output is partially correct - 712830 bits used |
10 |
Incorrect |
299 ms |
26408 KB |
Error - Not putting back color when it is not on the scaffold |