#include "advisor.h"
void ComputeAdvice(int *C, int N, int K, int M) {
int x = 1;
while (N > (1 << x)) x++;
for (int i = 0; i < N; i++) {
for (int j = 0; j < x; j++) {
//printf("%c", '0' + !!(C[i] & (1 << j)));
WriteAdvice(!!(C[i] & (1 << j)));
}
}
//printf("\n");
}
#include <bits/stdc++.h>
#include "assistant.h"
#define X first
#define Y second
using namespace std;
const int maxn = 1e5+10;
queue< int > qs[maxn];
void Assist(unsigned char *A, int N, int K, int R) {
int x = 1;
while (N > (1 << x)) x++;
int ptr = 0;
vector< int > c;
for (int i = 0; i < N; i++) {
int ac = 0;
for (int j = 0; j < x; j++) {
//printf("pokusaj: %c\n", A[ptr]);
if (A[ptr++] == 1) ac += (1 << j);
}
c.push_back(ac);
}
//printf("\n");
for (int i = 0; i < N; i++) {
qs[c[i]].push(i);
}
for (int i = 0; i < N; i++) qs[i].push(N + 1);
set< pair<int, int> > s;
for (int i = 0; i < K; i++) {
s.insert({-qs[i].front(), i});
}
for (int i = 0; i < N; i++) {
int deb = GetRequest();
//printf("debug: %d %d\n", deb, c[i]); fflush(stdout);
assert(c[i] == deb);
int tr = c[i];
//for (auto iter : s) printf("(%d %d) ", iter.X, iter.Y);
//printf("\n");
if (!s.count({-qs[tr].front(), tr})) {
int x = s.begin()->Y;
PutBack(x);
s.erase(s.begin());
qs[tr].pop();
s.insert({-qs[tr].front(), tr});
} else {
s.erase({-qs[tr].front(), tr});
qs[tr].pop();
s.insert({-qs[tr].front(), tr});
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
67804 KB |
Output is correct |
2 |
Correct |
34 ms |
67944 KB |
Output is correct |
3 |
Correct |
35 ms |
68068 KB |
Output is correct |
4 |
Correct |
37 ms |
68168 KB |
Output is correct |
5 |
Correct |
40 ms |
68376 KB |
Output is correct |
6 |
Correct |
40 ms |
68396 KB |
Output is correct |
7 |
Correct |
40 ms |
68420 KB |
Output is correct |
8 |
Correct |
41 ms |
68388 KB |
Output is correct |
9 |
Correct |
44 ms |
68388 KB |
Output is correct |
10 |
Correct |
45 ms |
68456 KB |
Output is correct |
11 |
Correct |
45 ms |
68348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
69060 KB |
Output is correct |
2 |
Correct |
160 ms |
74552 KB |
Output is correct |
3 |
Correct |
330 ms |
83280 KB |
Output is correct |
4 |
Correct |
302 ms |
81976 KB |
Output is correct |
5 |
Correct |
329 ms |
81816 KB |
Output is correct |
6 |
Correct |
308 ms |
81952 KB |
Output is correct |
7 |
Correct |
318 ms |
82436 KB |
Output is correct |
8 |
Correct |
278 ms |
80596 KB |
Output is correct |
9 |
Correct |
286 ms |
81572 KB |
Output is correct |
10 |
Correct |
328 ms |
83008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
260 ms |
78960 KB |
Output is correct |
2 |
Incorrect |
44 ms |
70740 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
67848 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
322 ms |
81252 KB |
Output is partially correct - 1700000 bits used |
2 |
Correct |
356 ms |
81476 KB |
Output is partially correct - 1700000 bits used |
3 |
Correct |
323 ms |
81476 KB |
Output is partially correct - 1700000 bits used |
4 |
Correct |
331 ms |
81776 KB |
Output is partially correct - 1700000 bits used |
5 |
Correct |
360 ms |
81572 KB |
Output is partially correct - 1700000 bits used |
6 |
Correct |
323 ms |
81688 KB |
Output is partially correct - 1700000 bits used |
7 |
Correct |
322 ms |
81508 KB |
Output is partially correct - 1697263 bits used |
8 |
Correct |
320 ms |
81496 KB |
Output is partially correct - 1700000 bits used |
9 |
Correct |
325 ms |
81564 KB |
Output is partially correct - 1700000 bits used |
10 |
Correct |
325 ms |
81560 KB |
Output is partially correct - 1700000 bits used |