#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(N);
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(N), ptr = 0;
for (int i = 0; i < N; i++) {
GetRequest();
if (A[ptr] == 0) {
ptr++;
continue;
}
else {
ptr++;
int val = 0;
rep(j, 0, LOG - 1) {
if (A[ptr + j] == 1) val |= 1 << j;
}
ptr += LOG;
// cerr << val << " -> " << endl;
PutBack(val);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
9968 KB |
Output is correct |
2 |
Incorrect |
8 ms |
9968 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 |
30 ms |
11504 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
236 ms |
22712 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 |
10 ms |
10480 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
303 ms |
25936 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
296 ms |
25704 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
298 ms |
26096 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
295 ms |
25960 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
293 ms |
26096 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
300 ms |
25848 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
294 ms |
25840 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
295 ms |
25840 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
296 ms |
25840 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
363 ms |
28408 KB |
Error - Putting back a color that is not on the scaffold |