#include "advisor.h"
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pp pop_back
#define sz(x) (int)x.size()
#define rep(z, a, b) for (int z = (a); (z) <= (b); z++)
#define per(z, a, b) for (int z = (a); (z) >= (b); z--)
using namespace std;
const int MAXN = (int)2e5 + 7;
vector <int> nxt[MAXN];
set <int> in;
set < pair <int, int > > dp;
void ComputeAdvice(int *C, int N, int K, int M) {
rep(i, 0, N - 1) {
nxt[i].pb(N);
}
per(i, N - 1, 0) {
nxt[C[i]].pb(i);
}
rep(i, 0, K - 1) {
in.insert(i);
dp.insert({nxt[i].back(), i});
}
int LOG = log2(N);
rep(i, 0, N - 1) {
if (in.count(C[i])) {
WriteAdvice(0);
continue;
}
while (sz(in) && dp.begin() -> f <= i) {
int x = dp.begin() -> s;
dp.erase(dp.begin());
nxt[x].pp();
dp.insert({nxt[x].back(), x});
}
int del = dp.rbegin() -> s;
dp.erase(--dp.end());
in.erase(del);
in.insert(C[i]);
dp.insert({nxt[C[i]].back(), C[i]});
WriteAdvice(1);
// cerr << "PUT -> " << del << endl;
rep(j, 0, LOG) {
if (del & (1 << j)) WriteAdvice(1);
else WriteAdvice(0);
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pp pop_back
#define sz(x) (int)x.size()
#define rep(z, a, b) for (int z = (a); (z) <= (b); z++)
#define per(z, a, b) for (int z = (a); (z) >= (b); z--)
using namespace std;
const int MAXN = (int)2e5 + 7;
void Assist(unsigned char *A, int N, int K, int R) {
int LOG = log2(N);
for (int i = 0; i < R; ) {
GetRequest();
if (A[i] == 0) {
i++;
continue;
}
else {
i++;
int val = 0;
rep(j, 0, LOG) {
if (A[i + j] == 1) val |= 1 << j;
}
i += LOG + 1;
// cerr << val << " -> " << endl;
PutBack(val);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
9968 KB |
Output is correct |
2 |
Correct |
8 ms |
9968 KB |
Output is correct |
3 |
Correct |
9 ms |
10224 KB |
Output is correct |
4 |
Correct |
16 ms |
10480 KB |
Output is correct |
5 |
Incorrect |
11 ms |
10480 KB |
Error - advice is too long |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
11760 KB |
Output is correct |
2 |
Correct |
147 ms |
18672 KB |
Output is correct |
3 |
Correct |
418 ms |
32496 KB |
Output is correct |
4 |
Correct |
461 ms |
29936 KB |
Output is correct |
5 |
Correct |
449 ms |
29424 KB |
Output is correct |
6 |
Correct |
425 ms |
28576 KB |
Output is correct |
7 |
Correct |
432 ms |
29224 KB |
Output is correct |
8 |
Correct |
375 ms |
29424 KB |
Output is correct |
9 |
Correct |
437 ms |
30904 KB |
Output is correct |
10 |
Correct |
378 ms |
30400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
310 ms |
25224 KB |
Output is correct |
2 |
Correct |
378 ms |
29680 KB |
Output is correct |
3 |
Correct |
379 ms |
29616 KB |
Output is correct |
4 |
Correct |
359 ms |
29424 KB |
Output is correct |
5 |
Correct |
306 ms |
27960 KB |
Output is correct |
6 |
Correct |
371 ms |
29680 KB |
Output is correct |
7 |
Correct |
371 ms |
29800 KB |
Output is correct |
8 |
Correct |
456 ms |
32240 KB |
Output is correct |
9 |
Correct |
250 ms |
28752 KB |
Output is correct |
10 |
Correct |
368 ms |
29680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
10480 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
379 ms |
28600 KB |
Output is partially correct - 975347 bits used |
2 |
Partially correct |
390 ms |
28656 KB |
Output is partially correct - 941041 bits used |
3 |
Partially correct |
381 ms |
29072 KB |
Output is partially correct - 907466 bits used |
4 |
Partially correct |
368 ms |
29176 KB |
Output is partially correct - 906939 bits used |
5 |
Partially correct |
365 ms |
28912 KB |
Output is partially correct - 905358 bits used |
6 |
Partially correct |
373 ms |
28944 KB |
Output is partially correct - 907109 bits used |
7 |
Partially correct |
372 ms |
29168 KB |
Output is partially correct - 905741 bits used |
8 |
Partially correct |
369 ms |
28968 KB |
Output is partially correct - 908452 bits used |
9 |
Partially correct |
373 ms |
29168 KB |
Output is partially correct - 907874 bits used |
10 |
Partially correct |
455 ms |
31880 KB |
Output is partially correct - 1366636 bits used |