#include "advisor.h"
#include <bits/stdc++.h>
#ifdef local
#define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__)
template <typename H, typename ...T>
void qqbx(const char *s, const H& h, T &&...args) {
for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s;
std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n");
if constexpr(sizeof...(T)) qqbx(++s, args...);
}
#define safe \
std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
using namespace std;
void ComputeAdvice(int *C, int n, int k, int m) {
int L = __lg(n-1)+1;
debug(L);
auto W = [&](int x) -> void {
for(int i = L-1; i >= 0; i--) WriteAdvice(x >> i & 1);
};
vector<bool> ok(n);
for(int i = 0; i < k; i++) ok[i] = true;
vector<int> nxt(n), last(n, 1e9);
for(int i = n-1; i >= 0; i--) {
nxt[i] = last[C[i]];
last[C[i]] = i;
}
priority_queue<pair<int,int>> pq;
for(int i = 0; i < k; i++) pq.push({last[i], i});
for(int i = 0; i < n; i++) {
int r = C[i];
if(!ok[r]) {
int x = pq.top().second; pq.pop();
W(x);
ok[x] = false;
ok[r] = true;
pq.push({nxt[i], r});
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#ifdef local
#define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__)
template <typename H, typename ...T>
void qqbx(const char *s, const H& h, T &&...args) {
for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s;
std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n");
if constexpr(sizeof...(T)) qqbx(++s, args...);
}
#define safe \
std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
using namespace std;
void Assist(unsigned char *A, int n, int k, int len) {
int L = __lg(n-1)+1;
int p = 0;
auto nextint = [&]() -> int {
int res = 0;
for(int i = 0; i < L; i++) {
res = res * 2 + A[p++];
}
return res;
};
vector<bool> ok(n);
for(int i = 0; i < k; i++) ok[i] = true;
for(int i = 0; i < n; i++) {
int r = GetRequest();
if(!ok[r]) {
int x = nextint();
PutBack(x);
ok[x] = false;
ok[r] = true;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
776 KB |
Output is correct |
2 |
Incorrect |
1 ms |
776 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
1940 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
219 ms |
8504 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
960 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
293 ms |
11032 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
281 ms |
10796 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
260 ms |
10344 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
268 ms |
10184 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
263 ms |
10188 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
264 ms |
10184 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
262 ms |
10280 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
276 ms |
10312 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
261 ms |
10188 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
315 ms |
11688 KB |
Output is partially correct - 1266636 bits used |