#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];
void ComputeAdvice(int *C, int N, int K, int M) {
per(i, N - 1, 0) nxt[i].pb(N);
per(i, N - 1, 0) nxt[C[i]].pb(i);
set < pair <int, int > > st;
rep(i, 0, K - 1) st.insert({nxt[i].back(), i});
int Log = log2(K);
rep(i, 0, N - 1) {
while (sz(st) && st.begin() -> f <= i) {
int x = st.begin() -> s;
st.erase(st.begin());
nxt[x].pp();
st.insert({nxt[x].back(), x});
}
if (st.count({nxt[C[i]].back(), C[i]})) {
WriteAdvice(0);
continue;
}
int del = st.rbegin() -> s;
st.erase(--st.end());
st.insert({nxt[C[i]].back(), C[i]});
WriteAdvice(1);
rep(j, 0, Log - 1) {
WriteAdvice((del >> j) & 1);
}
}
}
#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(K);
for (int i = 0; i < R; ) {
GetRequest();
if (A[i] == 0) {
i++;
continue;
}
else {
i++;
int val = 0;
rep(j, 0, LOG - 1) {
if (A[i + j] == 1) val |= 1 << j;
}
i += LOG ;
// cerr << val << " -> " << endl;
PutBack(val);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
9968 KB |
Output is correct |
2 |
Incorrect |
9 ms |
9976 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
11504 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
225 ms |
23536 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
10480 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
291 ms |
26360 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
273 ms |
26352 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
272 ms |
26424 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
303 ms |
26752 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
281 ms |
26720 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
284 ms |
26968 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
284 ms |
26808 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
280 ms |
26768 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
270 ms |
26488 KB |
Error - Not putting back color when it is not on the scaffold |
10 |
Incorrect |
328 ms |
28808 KB |
Error - Not putting back color when it is not on the scaffold |