// In the name of Allah
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> cld;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0)
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
static int n, k, m;
const static int maxn = 2e5 + 7;
static int A[maxn], val[maxn], ind[maxn];
static int M[maxn], res[maxn];
static set<pii> st;
void WriteAdvice(unsigned char a);
void ComputeAdvice(int C[], int Nx, int Kx, int Mx) {
n = Nx; k = Kx; m = Mx;
n += k;
for (int i = 0; i < k; i++) A[i] = i;
for (int i = k; i < n; i++) A[i] = C[i - k];
fill(ind, ind + n, n);
for (int i = n - 1; i >= 0; i--) {
val[i] = ind[A[i]];
ind[A[i]] = i;
}
st.clear();
fill(M, M + n, -1); fill(res, res + n, 1);
for (int i = 0; i < k; i++) {
st.insert(Mp(val[i], i));
M[A[i]] = i;
}
for (int i = k; i < n; i++) {
int j = M[A[i]];
if (j != -1) {
st.erase(Mp(val[j], j));
st.insert(Mp(val[i], i));
M[A[i]] = i;
}
else {
auto f = *st.rbegin();
int r = f.S; st.erase(f);
res[r] = 0; M[A[r]] = -1;
st.insert(Mp(val[i], i));
M[A[i]] = i;
}
}
for (int i = 0; i < n; i++) {
if (res[i]) WriteAdvice('1');
else WriteAdvice('0');
}
}
// In the name of Allah
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> cld;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0)
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
static int n, k, m;
const static int maxn = 2e5 + 7;
static int A[maxn], M[maxn];
static set<pii> st;
void PutBack(int T);
int GetRequest();
void Assist(unsigned char res[], int Nx, int Kx, int Rx) {
n = Nx; k = Kx; m = Rx;
n += k;
fill(M, M + n, -1);
for (int i = 0; i < k; i++) {
st.insert(Mp(res[i] - '0', i));
A[i] = i; M[A[i]] = i;
}
for (int i = k; i < n; i++) {
A[i] = GetRequest();
if (M[A[i]] != -1) {
int j = M[A[i]];
auto f = Mp(res[j] - '0', j); st.erase(f);
M[A[i]] = -1;
}
else {
auto f = *st.begin();
int j = f.S; st.erase(f);
M[A[j]] = -1; PutBack(A[j]);
}
st.insert(Mp(res[i] - '0', i));
M[A[i]] = i;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2852 KB |
Error - advice must be 0 or 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
3160 KB |
Error - advice must be 0 or 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
5852 KB |
Error - advice must be 0 or 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3108 KB |
Error - advice must be 0 or 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
6476 KB |
Error - advice must be 0 or 1 |
2 |
Incorrect |
30 ms |
6476 KB |
Error - advice must be 0 or 1 |
3 |
Incorrect |
31 ms |
6660 KB |
Error - advice must be 0 or 1 |
4 |
Incorrect |
32 ms |
6808 KB |
Error - advice must be 0 or 1 |
5 |
Incorrect |
32 ms |
6796 KB |
Error - advice must be 0 or 1 |
6 |
Incorrect |
31 ms |
6724 KB |
Error - advice must be 0 or 1 |
7 |
Incorrect |
31 ms |
6744 KB |
Error - advice must be 0 or 1 |
8 |
Incorrect |
31 ms |
6724 KB |
Error - advice must be 0 or 1 |
9 |
Incorrect |
32 ms |
6752 KB |
Error - advice must be 0 or 1 |
10 |
Incorrect |
25 ms |
6648 KB |
Error - advice must be 0 or 1 |