#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[i].push(N + 1);
for (int i = 0; i < N; i++) {
qs[c[i]].push(i);
}
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];
if (!s.count({qs[tr].front(), tr})) {
int x = s.rbegin()->Y;
PutBack(x);
s.erase(--s.end());
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 |
Incorrect |
32 ms |
67848 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
54 ms |
69060 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
254 ms |
79708 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
67904 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
316 ms |
82444 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
320 ms |
82584 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
313 ms |
82684 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
314 ms |
82664 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
329 ms |
82704 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
319 ms |
82812 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
361 ms |
82680 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
351 ms |
82688 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
314 ms |
82704 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
312 ms |
82920 KB |
Output isn't correct - not an optimal way |