#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]) continue;
pair<int, int> nxt = make_pair(0, 0);
for(int j = 0; j < N; j++) if (chosen[j]) {
int head = N;
for(int k = i; k < N; k++) if (query[k] == j) {
head = k;
break;
}
nxt = max(nxt, make_pair(head, j));
}
int j = nxt.second;
chosen[j] = 0;
PutBack(j);
chosen[x] = 1;
// if (chosen[x] == 0) {
// int useless, j; tie(useless, j) = Q.top(); Q.pop();
// chosen[j] = 0;
// PutBack(j);
//
// chosen[x] = 1;
// nxt[x].pop_back();
// int tmp = nxt[x].empty() ? N : nxt[x].back();
// Q.push({tmp, x});
// }
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3080 KB |
Output is correct |
2 |
Correct |
1 ms |
3092 KB |
Output is correct |
3 |
Correct |
2 ms |
3120 KB |
Output is correct |
4 |
Correct |
12 ms |
3188 KB |
Output is correct |
5 |
Correct |
31 ms |
3776 KB |
Output is correct |
6 |
Correct |
104 ms |
3780 KB |
Output is correct |
7 |
Correct |
245 ms |
3776 KB |
Output is correct |
8 |
Correct |
2127 ms |
3824 KB |
Output is correct |
9 |
Correct |
1377 ms |
4028 KB |
Output is correct |
10 |
Correct |
2260 ms |
3768 KB |
Output is correct |
11 |
Correct |
1558 ms |
3776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2584 ms |
4444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2596 ms |
16004 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3220 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2585 ms |
19116 KB |
Time limit exceeded |
2 |
Execution timed out |
2509 ms |
18840 KB |
Time limit exceeded |
3 |
Execution timed out |
2592 ms |
19136 KB |
Time limit exceeded |
4 |
Execution timed out |
2597 ms |
19124 KB |
Time limit exceeded |
5 |
Execution timed out |
2582 ms |
19000 KB |
Time limit exceeded |
6 |
Execution timed out |
2582 ms |
18944 KB |
Time limit exceeded |
7 |
Execution timed out |
2547 ms |
18896 KB |
Time limit exceeded |
8 |
Execution timed out |
2579 ms |
18868 KB |
Time limit exceeded |
9 |
Execution timed out |
2568 ms |
18936 KB |
Time limit exceeded |
10 |
Execution timed out |
2573 ms |
20392 KB |
Time limit exceeded |