#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
int T = log2(N) + 1;
for(int i = 0; i < N; i++) {
for(int j = 0; j < T; j++) WriteAdvice(C[i] >> j & 1);
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int query[N];
bool chosen[N];
vector<int> nxt[N];
void Assist(unsigned char *A, int N, int K, int R) {
int T = log2(N) + 1;
int cnt = 0;
for(int i = 0; i < N; i++) {
for(int j = 0; j < T; j++) {
if (int(A[cnt])) query[i] |= (1 << j);
cnt++;
}
}
for(int i = N - 1; i >= 0; i--) nxt[query[i]].push_back(i);
priority_queue<pair<int, int> > Q;
for(int i = 0; i < K; i++) {
int tmp = nxt[i].empty() ? N : nxt[i].back();
Q.push({tmp, i});
chosen[i] = 1;
}
for(int i = 0; i < N; i++) {
GetRequest();
int x = query[i];
if (chosen[x] == 0) {
if (Q.empty()) return;
int useless, j; tie(useless, j) = Q.top(); Q.pop();
chosen[j] = 0;
PutBack(j);
chosen[x] = 1;
if (nxt[x].empty()) return;
nxt[x].pop_back();
int tmp = nxt[x].empty() ? N : nxt[i].back();
Q.push({tmp, x});
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3084 KB |
Output is correct |
2 |
Runtime error |
3 ms |
5652 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
28 ms |
7488 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
226 ms |
21616 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3344 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
279 ms |
25272 KB |
Execution killed with signal 11 |
2 |
Runtime error |
278 ms |
25540 KB |
Execution killed with signal 11 |
3 |
Runtime error |
277 ms |
25576 KB |
Execution killed with signal 11 |
4 |
Runtime error |
274 ms |
25312 KB |
Execution killed with signal 11 |
5 |
Runtime error |
281 ms |
25568 KB |
Execution killed with signal 11 |
6 |
Runtime error |
275 ms |
25576 KB |
Execution killed with signal 11 |
7 |
Runtime error |
282 ms |
25844 KB |
Execution killed with signal 11 |
8 |
Runtime error |
306 ms |
25556 KB |
Execution killed with signal 11 |
9 |
Runtime error |
286 ms |
25660 KB |
Execution killed with signal 11 |
10 |
Runtime error |
302 ms |
27844 KB |
Execution killed with signal 11 |