#include <bits/stdc++.h>
#include "advisor.h"
template <class T>
using Vec = std::vector<T>;
void write(const int width, const int bit) {
for (int i = 0; i < width; ++i) {
WriteAdvice(bit >> i & 1);
}
}
void ComputeAdvice(int *C, int N, int K, int M) {
Vec<Vec<int>> idx(N);
for (int i = 0; i < N; ++i) {
idx[i].push_back(N);
}
for (int i = N - 1; i >= 0; --i) {
idx[C[i]].push_back(i);
}
std::map<int, int> map;
std::set<std::pair<int, int>> que;
for (int i = 0; i < K; ++i) {
map[i] = i;
que.emplace(idx[i].back(), i);
}
for (int i = 0; i < N; ++i) {
if (que.find(std::make_pair(idx[C[i]].back(), C[i])) == que.end()) {
const auto [t, j] = *que.rbegin();
que.erase(std::make_pair(t, j));
write(N <= 5000 ? 13 : 15, map[j]);
map[C[i]] = map[j];
}
else {
write(N <= 5000 ? 13 : 15, K);
que.erase(std::make_pair(idx[C[i]].back(), C[i]));
}
idx[C[i]].pop_back();
que.emplace(idx[C[i]].back(), C[i]);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
template <class T>
using Vec = std::vector<T>;
int read(unsigned char *A, const int width) {
static int idx = 0;
int bit = 0;
for (int i = 0; i < width; ++i) {
if (A[idx++]) {
bit += 1 << i;
}
}
return bit;
}
void Assist(unsigned char *A, int N, int K, int R) {
std::map<int, int> map;
Vec<int> cur(K);
for (int i = 0; i < K; ++i) {
cur[i] = i;
}
for (int i = 0; i < N; ++i) {
const auto c = GetRequest();
const auto k = read(A, N <= 5000 ? 13 : 15);
if (k != K) {
const auto j = cur[k];
PutBack(j);
cur[k] = c;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
496 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
5 ms |
752 KB |
Output is correct |
4 |
Correct |
14 ms |
1100 KB |
Output is correct |
5 |
Correct |
23 ms |
1540 KB |
Output is correct |
6 |
Correct |
25 ms |
1536 KB |
Output is correct |
7 |
Correct |
19 ms |
1464 KB |
Output is correct |
8 |
Correct |
20 ms |
1644 KB |
Output is correct |
9 |
Correct |
23 ms |
1580 KB |
Output is correct |
10 |
Correct |
22 ms |
1668 KB |
Output is correct |
11 |
Correct |
22 ms |
1540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
2380 KB |
Output is correct |
2 |
Correct |
233 ms |
9572 KB |
Output is correct |
3 |
Incorrect |
523 ms |
21928 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
391 ms |
16496 KB |
Output is correct |
2 |
Correct |
515 ms |
20504 KB |
Output is correct |
3 |
Correct |
587 ms |
20616 KB |
Output is correct |
4 |
Correct |
506 ms |
20424 KB |
Output is correct |
5 |
Correct |
465 ms |
19324 KB |
Output is correct |
6 |
Correct |
495 ms |
20604 KB |
Output is correct |
7 |
Correct |
539 ms |
20600 KB |
Output is correct |
8 |
Correct |
504 ms |
21820 KB |
Output is correct |
9 |
Correct |
452 ms |
20012 KB |
Output is correct |
10 |
Correct |
520 ms |
20560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
888 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
508 ms |
20340 KB |
Output is partially correct - 1500000 bits used |
2 |
Correct |
513 ms |
20524 KB |
Output is partially correct - 1500000 bits used |
3 |
Correct |
510 ms |
20672 KB |
Output is partially correct - 1500000 bits used |
4 |
Correct |
502 ms |
20636 KB |
Output is partially correct - 1500000 bits used |
5 |
Correct |
498 ms |
20552 KB |
Output is partially correct - 1500000 bits used |
6 |
Correct |
496 ms |
20608 KB |
Output is partially correct - 1500000 bits used |
7 |
Correct |
519 ms |
20624 KB |
Output is partially correct - 1497585 bits used |
8 |
Correct |
505 ms |
20632 KB |
Output is partially correct - 1500000 bits used |
9 |
Correct |
495 ms |
20796 KB |
Output is partially correct - 1500000 bits used |
10 |
Correct |
511 ms |
21676 KB |
Output is partially correct - 1500000 bits used |