#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];
nxt[x].pop_back();
while (!Q.empty() && chosen[Q.top().second] == 0) Q.pop();
if (chosen[x] == 0) {
int useless, j; tie(useless, j) = Q.top(); Q.pop();
chosen[j] = 0;
PutBack(j);
chosen[x] = 1;
int tmp = nxt[x].empty() ? N : nxt[x].back();
Q.push({tmp, x});
}
else {
Q.push({nxt[x].empty() ? N : nxt[x].back(), x});
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3100 KB |
Output is correct |
2 |
Correct |
1 ms |
3400 KB |
Output is correct |
3 |
Correct |
2 ms |
3112 KB |
Output is correct |
4 |
Correct |
7 ms |
3184 KB |
Output is correct |
5 |
Correct |
13 ms |
3784 KB |
Output is correct |
6 |
Correct |
12 ms |
3776 KB |
Output is correct |
7 |
Correct |
12 ms |
3776 KB |
Output is correct |
8 |
Correct |
12 ms |
3768 KB |
Output is correct |
9 |
Correct |
12 ms |
3768 KB |
Output is correct |
10 |
Correct |
15 ms |
3776 KB |
Output is correct |
11 |
Correct |
12 ms |
3784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
4500 KB |
Output is correct |
2 |
Correct |
129 ms |
10612 KB |
Output is correct |
3 |
Correct |
284 ms |
20948 KB |
Output is correct |
4 |
Correct |
271 ms |
18840 KB |
Output is correct |
5 |
Correct |
281 ms |
19196 KB |
Output is correct |
6 |
Correct |
272 ms |
19572 KB |
Output is correct |
7 |
Correct |
282 ms |
20124 KB |
Output is correct |
8 |
Correct |
230 ms |
18276 KB |
Output is correct |
9 |
Correct |
259 ms |
17480 KB |
Output is correct |
10 |
Correct |
285 ms |
19924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
231 ms |
15836 KB |
Output is correct |
2 |
Incorrect |
13 ms |
5992 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3088 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
282 ms |
18896 KB |
Output is partially correct - 1700000 bits used |
2 |
Correct |
285 ms |
18716 KB |
Output is partially correct - 1700000 bits used |
3 |
Correct |
276 ms |
18872 KB |
Output is partially correct - 1700000 bits used |
4 |
Correct |
295 ms |
19284 KB |
Output is partially correct - 1700000 bits used |
5 |
Correct |
289 ms |
18824 KB |
Output is partially correct - 1700000 bits used |
6 |
Correct |
274 ms |
18896 KB |
Output is partially correct - 1700000 bits used |
7 |
Correct |
279 ms |
18988 KB |
Output is partially correct - 1697263 bits used |
8 |
Correct |
274 ms |
18976 KB |
Output is partially correct - 1700000 bits used |
9 |
Correct |
277 ms |
19136 KB |
Output is partially correct - 1700000 bits used |
10 |
Correct |
275 ms |
19432 KB |
Output is partially correct - 1700000 bits used |