#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), 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);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
9912 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
11512 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
223 ms |
23056 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
10480 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
278 ms |
26040 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
277 ms |
25928 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
278 ms |
26096 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
277 ms |
26296 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
275 ms |
26096 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
275 ms |
26096 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
277 ms |
26480 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
276 ms |
26024 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
273 ms |
26096 KB |
Error - Not putting back color when it is not on the scaffold |
10 |
Incorrect |
326 ms |
28144 KB |
Error - Not putting back color when it is not on the scaffold |