//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "advisor.h"
//#include "grader.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long int ll;
const int MAXN = 2e5 + 5;
int val[MAXN], ind[MAXN], nx[MAXN], ans[MAXN];
int last[MAXN];
bool mrk[MAXN];
// active -> 0, passive -> 1
void ComputeAdvice(int *C, int n, int k, int m) {
priority_queue<pii> pq;
for (int i = 0; i < n; i++)
ind[i] = n + k + 1;
memset(last, -1, sizeof last);
for (int i = n - 1; i > -1; i--) {
val[k + i] = ind[C[i]];
ind[C[i]] = k + i;
}
for (int i = 0; i < k; i++) {
val[i] = ind[i];
ind[i] = i;
mrk[i] = 1;
pq.push({val[i], i});
}
for (int i = 0; i < n; i++) {
if (!mrk[C[i]]) {
pii cur = pq.top(); pq.pop();
int nx = (cur.se > k - 1) ? C[cur.se - k] : cur.se;
mrk[nx] = 0;
ans[cur.se] = 1;
mrk[C[i]] = 1;
}
pq.push({val[k + i], k + i});
}
for (int i = 0; i < n + k; i++)
WriteAdvice(ans[i]);
}
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "assistant.h"
//#include "grader.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long int ll;
const int MAXN = 2e5 + 5;
int mrk[MAXN];
vi arr;
void Assist(unsigned char *A, int n, int k, int R) {
for (int i = 0; i < k; i++) {
if (A[i])
arr.pb(i);
mrk[i] = 1;
}
for (int i = 0; i < n; i++) {
int col = GetRequest();
if (!mrk[col]) {
mrk[arr.back()] = 0;
PutBack(arr.back());
arr.pop_back();
}
if (A[k + i]) // passive
arr.pb(col);
mrk[col] = 1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2304 KB |
Output is correct |
2 |
Correct |
5 ms |
2304 KB |
Output is correct |
3 |
Correct |
5 ms |
2304 KB |
Output is correct |
4 |
Correct |
6 ms |
2560 KB |
Output is correct |
5 |
Correct |
7 ms |
2560 KB |
Output is correct |
6 |
Correct |
8 ms |
2560 KB |
Output is correct |
7 |
Correct |
9 ms |
2816 KB |
Output is correct |
8 |
Correct |
8 ms |
2560 KB |
Output is correct |
9 |
Correct |
8 ms |
2816 KB |
Output is correct |
10 |
Correct |
9 ms |
2816 KB |
Output is correct |
11 |
Correct |
9 ms |
2872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
3128 KB |
Output is correct |
2 |
Correct |
34 ms |
5880 KB |
Output is correct |
3 |
Correct |
68 ms |
9648 KB |
Output is correct |
4 |
Correct |
64 ms |
8688 KB |
Output is correct |
5 |
Correct |
75 ms |
8680 KB |
Output is correct |
6 |
Correct |
77 ms |
8912 KB |
Output is correct |
7 |
Correct |
126 ms |
9440 KB |
Output is correct |
8 |
Correct |
70 ms |
8176 KB |
Output is correct |
9 |
Correct |
81 ms |
8656 KB |
Output is correct |
10 |
Correct |
73 ms |
9376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
7976 KB |
Output is correct |
2 |
Correct |
86 ms |
9528 KB |
Output is correct |
3 |
Correct |
80 ms |
9240 KB |
Output is correct |
4 |
Correct |
110 ms |
9184 KB |
Output is correct |
5 |
Correct |
71 ms |
9200 KB |
Output is correct |
6 |
Correct |
69 ms |
9232 KB |
Output is correct |
7 |
Correct |
68 ms |
9200 KB |
Output is correct |
8 |
Correct |
80 ms |
9168 KB |
Output is correct |
9 |
Correct |
75 ms |
8888 KB |
Output is correct |
10 |
Correct |
69 ms |
9232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2648 KB |
Output is correct |
2 |
Correct |
9 ms |
2560 KB |
Output is correct |
3 |
Correct |
6 ms |
2560 KB |
Output is correct |
4 |
Correct |
9 ms |
2560 KB |
Output is correct |
5 |
Correct |
8 ms |
2560 KB |
Output is correct |
6 |
Correct |
10 ms |
2560 KB |
Output is correct |
7 |
Correct |
9 ms |
2816 KB |
Output is correct |
8 |
Correct |
8 ms |
2560 KB |
Output is correct |
9 |
Correct |
8 ms |
2816 KB |
Output is correct |
10 |
Correct |
10 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
9384 KB |
Output is correct - 120000 bits used |
2 |
Correct |
82 ms |
9416 KB |
Output is correct - 122000 bits used |
3 |
Correct |
78 ms |
9448 KB |
Output is correct - 125000 bits used |
4 |
Correct |
82 ms |
9240 KB |
Output is correct - 125000 bits used |
5 |
Correct |
96 ms |
9232 KB |
Output is correct - 125000 bits used |
6 |
Correct |
85 ms |
9440 KB |
Output is correct - 125000 bits used |
7 |
Correct |
82 ms |
9296 KB |
Output is correct - 124828 bits used |
8 |
Correct |
125 ms |
9432 KB |
Output is correct - 124910 bits used |
9 |
Correct |
97 ms |
9232 KB |
Output is correct - 125000 bits used |
10 |
Correct |
89 ms |
9416 KB |
Output is correct - 125000 bits used |